randydev commited on
Commit
2eb85f7
·
verified ·
1 Parent(s): 2a1da11

Create fluxai.js

Browse files
Files changed (1) hide show
  1. fluxai.js +25 -0
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
+ }