CCCPaste

fluximage

const axios = require("axios")

/**
 * Flux Image Generator
 * Função utilitária para gerar imagens a partir de nihalgazi-flux-unlimited.hf.space.
 * 
 * @param {string} prompt - O texto que descreve a imagem desejada.
 * @param {number} [width=1024] - Largura da imagem.
 * @param {number} [height=1024] - Altura da imagem.
 * @param {string} [server="Google US Server"] - Nome do servidor para geração.
 * @returns {Promise} - Retorna a URL da imagem gerada ou null em caso de falha.
 * 
 * @author synshin9
 *
 * @By: 𖧄 𝐋𝐔𝐂𝐀𝐒 𝐌𝐎𝐃 𝐃𝐎𝐌𝐈𝐍𝐀 𖧄
 * Canal: https://whatsapp.com/channel/0029Vb69bDnAe5VmzSMwBH11
 *
 * SERVIDORES DE LISTAS:
 * NSFW-Core: Uncensored Server
 * NSFW-Core: Uncensored Server 2
 * NSFW-Core: Uncensored Server 3
 * NSFW-Core: Uncensored Server 4
 * Azure Lite Supercomputer Server
 * Artemis GPU Super cluster
 * NebulaDrive Tensor Server
 * PixelNet NPU Server
 * Google US Server
 * 
 * ⚠️ Atenção:
 * O servidor NSFW-Core pode gerar conteúdo adulto. Você deve ser maior de idade em sua jurisdição e cumprir todas as leis locais e políticas da plataforma. O desenvolvedor não se responsabiliza pelo uso indevido.
 */
 
async function fluxImage(prompt, width = 1024, height = 1024, server = "NSFW-Core: Uncensored Server 2") {
try {
const { data: init } = await axios.post(
"https://nihalgazi-flux-unlimited.hf.space/gradio_api/call/generate_image",
{ data: [prompt, width, height, 3, true, server] },
{
headers: {
"Content-Type": "application/json",
Origin: "https://chrunos.com",
Referer: "https://chrunos.com/",
},
}
);
const eventId = init.event_id;
if (!eventId) throw new Error("Não foi possível obter o event_id.");
const streamUrl = `https://nihalgazi-flux-unlimited.hf.space/gradio_api/call/generate_image/${eventId}`;
let imageUrl = null;
for (let i = 0; i < 15; i++) {
const { data } = await axios.get(streamUrl, {
headers: { Accept: "text/event-stream" },
});
const match = data.match(/"url":\s*"([^"]+)"/);
if (match) {
imageUrl = match[1];
break;
}
await new Promise(r => setTimeout(r, 2000));
}
if (!imageUrl) throw new Error("Não foi possível recuperar o URL da imagem do fluxo.");
return imageUrl;
} catch (err) {
console.error("Error:", err.message);
return null;
}
}

module.exports = { fluxImage }