File size: 968 Bytes
2eb85f7
6b006e9
2eb85f7
eb92249
 
 
 
4192ae2
5a03baf
4192ae2
2eb85f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
902ac08
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
    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.buffer();
    } catch (error) {
        console.error("Error fetching data:", error.message);
        return null;
    }
}

export { schellwithflux };