ryu-js / fluxai.js
randydev's picture
Update fluxai.js
7d77877 verified
raw
history blame
973 Bytes
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 = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fblack-forest-labs%2FFLUX.1-schnell%26quot%3B%3C%2Fspan%3E%3B%3C!-- HTML_TAG_END -->
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 };