Файл call.js

//const { dalle } = require("./API/dalle");
const { aimultiple } = require("./API/aimultiple");
//const { pixart } = require("./API/pixart");
//const { prodia } = require("./API/prodia");
//const { stablediffusion } = require("./API/stablediffusion");

//const { uploadImage } = require("./image-upload/upload-img");

const fs = require('fs');

async function call() {
    try {
        
		let prompt = "New metal keychain in the shape of an Indian's head";
		
        
        let data = await aimultiple({
            prompt: prompt,
            prompt_negative: "",
            model: "midjourney"               // 3d-redmond | pixel-art | sdxl-anime | 3d-redmond | midjourney
        });
        
		return data;

    } catch (error) {
        console.log(error)
        console.log("error")
    }
}

let response = null;
let sleep = 5;
let pics = 20;

async function A(){
	
	for (let i = 0; i < pics; i++) {
		
		await new Promise(resolve => setTimeout(resolve, sleep*1000));
		response = await call();
		//console.log(response.images);
		
		let img = response.images[0];
		const base64String = img.split("base64,")[1]; // Получаем только часть с Base64
		// Декодируем Base64
		const buffer = Buffer.from(base64String, 'base64');

		// Сохраняем изображение в файл
		await fs.writeFile('image_' +  (i + 1) + '.jpg', buffer, (err) => {
		  if (err) {
			console.error('Ошибка при сохранении изображения:', err);
		  } else {
			console.log('Изображение успешно сохранено как image_' +  (i + 1) + '.jpg');
		  }
		});
	}

}

A();

Файл aimultiple.js

const axios = require("axios");
const { sleep } = require("./util");

const aimultiple = async ({
    prompt = "",
    prompt_negative = "",
    model = ""
}) => {
    return new Promise((res, rej) => {
        let datarender = {
            prompt: "",
            prompt_negative: "",
            model: "goofyai/3d_render_style_xl"
        }

        let model_name = "Render3D";

        try {
            if(prompt != undefined && prompt != null && (typeof prompt).toString().toLowerCase() === "String".toLowerCase() && prompt.toString().trim().length > 0){
                datarender.prompt = prompt.toString();
            } else {
                datarender.prompt = "";
            }
        } catch(e){
            datarender.prompt = "";
        }

        try {
            if(prompt_negative != undefined && prompt_negative != null && (typeof prompt_negative).toString().toLowerCase() === "String".toLowerCase() && prompt_negative.toString().trim().length > 0){
                datarender.prompt_negative = prompt_negative.toString();
            } else {
                datarender.prompt_negative = "";
            }
        } catch(e){
            datarender.prompt_negative = "";
        }

        try {
            if(model != undefined && model != null && (typeof model).toString().toLowerCase() === "String".toLowerCase() && model.toString().trim().length > 0){
                if(model.toString().toLowerCase() === "Render3D".toLowerCase()){
                    datarender.model = "goofyai/3d_render_style_xl";
                    model_name = "Render3D";
                } else if(model.toString().toLowerCase() === "pixel-art".toLowerCase()){
                    datarender.model = "nerijs/pixel-art-xl";
                    model_name = "PixelArt";
                } else if(model.toString().toLowerCase() === "sdxl-anime".toLowerCase()){
                    datarender.model = "ntc-ai/SDXL-LoRA-slider.anime";
                    model_name = "SDXL-Anime";
                } else if(model.toString().toLowerCase() === "3d-redmond".toLowerCase()){
                    datarender.model = "artificialguybr/3DRedmond-V1";
                    model_name = "3DRedmond";
                } else if(model.toString().toLowerCase() === "midjourney".toLowerCase()){
                    datarender.model = "XLabs-AI/flux-RealismLora";
                    model_name = "Midjourney";
                } else {
                    datarender.model = "goofyai/3d_render_style_xl";
                    model_name = "Render3D";
                }
            } else {
                datarender.model = "goofyai/3d_render_style_xl";
                model_name = "Render3D";
            }
        } catch(e){
            datarender.model = "goofyai/3d_render_style_xl";
            model_name = "Render3D";
        }

        let count = 0;
        async function goRenPixel(){
            try {
                await sleep(1000);
                axios.post("https://enzostvs-lora-studio.hf.space/api/generate", {
                    model: {
                        id: datarender.model
                    },
                    inputs: datarender.prompt,
                    parameters: {
                        negative_prompt: datarender.prompt_negative
                    }
                }, {
                    headers: {
                        'accept': 'text/event-stream',
                        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
                        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
                        'Accept-Language': 'en-US,en;q=0.5',
                        'Referer': 'https://enzostvs-lora-studio.hf.space/',
                        'authority': 'enzostvs-lora-studio.hf.space',
                        'Connection': 'keep-alive',
                        'Cache-Control': 'max-age=0',
                        'Upgrade-Insecure-Requests': '1'
                    }
                }).then((response) => {
                    if(response.status === 200 && response.data != undefined && response.data != null && response.data.image != undefined && response.data.image != null){
                        let img = response.data.image;
                        let images = [];
                        images.push("data:image/jpeg;base64," + img.split("base64,")[1].toString());
                        
                        if(model_name.toString().toLowerCase() != "midjourney"){
                            return res({
                                "code": 200,
                                "status": true,
                                "prompt": datarender.prompt != undefined ? datarender.prompt.toString() : "",
                                "model": model_name,
                                "data": {
                                    prompt_negative: datarender.prompt_negative
                                },
                                "images": images
                            });
                        } else {
                            return res({
                                "code": 200,
                                "status": true,
                                "prompt": datarender.prompt != undefined ? datarender.prompt.toString() : "",
                                "model": model_name,
                                "images": images
                            });
                        }
                    } else {
                        if(count > 10){
                            return rej({
                                "code": 500,
                                "status": false,
                                "error": "INTERNAL_SERVER_ERROR",
                                "message": "general (unknown) error"
                            });
                        } else {
                            count += 1;
                            setTimeout(function(){goRenPixel();});
                        }
                    }
                }).catch((err) => {
                    if(count > 10){
                        return rej({
                            "code": 500,
                            "status": false,
                            "error": "INTERNAL_SERVER_ERROR",
                            "message": "general (unknown) error"
                        });
                    } else {
                        count += 1;
                        setTimeout(function(){goRenPixel();});
                    }
                });
            } catch(e){
                if(count > 10){
                    return rej({
                        "code": 500,
                        "status": false,
                        "error": "INTERNAL_SERVER_ERROR",
                        "message": "general (unknown) error"
                    });
                } else {
                    count += 1;
                    setTimeout(function(){goRenPixel();});
                }
            }
        }
        setTimeout(function(){goRenPixel();});
    });
}

module.exports = {
    aimultiple
}

Перепиши этот код на php и сделай одним файлом