Spaces:
Paused
Paused
import fetch from "node-fetch"; | |
import * as config from './config.js'; | |
if (!config.HUGGING_TOKEN) { | |
throw new Error("Missing variable: HUGGING_TOKEN"); | |
} | |
/** | |
* @param {string} args - The input string | |
*/ | |
async function schellwithflux(args) { | |
const API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"; | |
try { | |
const response = await fetch(API_URL, { | |
method: "POST", | |
headers: { | |
"Authorization": `Bearer ${config.HUGGING_TOKEN}`, | |
"Content-Type": "application/json", | |
}, | |
body: JSON.stringify({ inputs: args }), | |
}); | |
if (!response.ok) { | |
console.error(`API Error: ${response.status}`); | |
return null; | |
} | |
return await response.arrayBuffer(); | |
} catch (error) { | |
console.error("Error fetching data:", error.message); | |
return null; | |
} | |
} | |
export { schellwithflux }; |