Create fluxai.js
Browse files
fluxai.js
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import fetch from "node-fetch";
|
2 |
+
import * as config from '.config.js'
|
3 |
+
|
4 |
+
async function schellwithflux(args) {
|
5 |
+
const API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell";
|
6 |
+
try {
|
7 |
+
const response = await fetch(API_URL, {
|
8 |
+
method: "POST",
|
9 |
+
headers: {
|
10 |
+
"Authorization": `Bearer ${config.HUGGING_TOKEN}`,
|
11 |
+
"Content-Type": "application/json",
|
12 |
+
},
|
13 |
+
body: JSON.stringify({ inputs: args }),
|
14 |
+
});
|
15 |
+
|
16 |
+
if (!response.ok) {
|
17 |
+
console.error(`API Error: ${response.status}`);
|
18 |
+
return null;
|
19 |
+
}
|
20 |
+
return await response.buffer();
|
21 |
+
} catch (error) {
|
22 |
+
console.error("Error fetching data:", error.message);
|
23 |
+
return null;
|
24 |
+
}
|
25 |
+
}
|