1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { fetch } from "https://esm.town/v/std/fetch";
export let stableDiffusionCreate = async (key, prompt) => {
const url = "https://api.replicate.com/v1/predictions";
const headers = {
Authorization: `Token ${key}`,
"Content-Type": "application/json",
};
const version =
"a9758cbfbd5f3c2094457d996681af52552901775aa2d6dd0b17fd15df959bef";
const data = { version: version, input: { prompt: prompt } };
const res = await fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(data),
});
return res.json();
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023