Skip to content

Commit 18d87cd

Browse files
committed
add testToImage fetch js
1 parent 5a288ab commit 18d87cd

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

packages/inference/src/snippets/templates/js/fetch/textToImage.jinja

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{% if provider == "hf-inference" %}
21
async function query(data) {
32
const response = await fetch(
43
"{{ fullUrl }}",
@@ -17,5 +16,4 @@ async function query(data) {
1716

1817
query({ inputs: {{ providerInputs.asObj.inputs }} }).then((response) => {
1918
// Use image
20-
});
21-
{% endif %}
19+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
async function query(data) {
2+
const response = await fetch(
3+
"https://fal.run/<fal-ai alias for black-forest-labs/FLUX.1-schnell>",
4+
{
5+
headers: {
6+
Authorization: "Key api_token",
7+
"Content-Type": "application/json",
8+
},
9+
method: "POST",
10+
body: JSON.stringify(data),
11+
}
12+
);
13+
const result = await response.blob();
14+
return result;
15+
}
16+
17+
query({ inputs: "Astronaut riding a horse" }).then((response) => {
18+
// Use image
19+
});

0 commit comments

Comments
 (0)