-
Notifications
You must be signed in to change notification settings - Fork 0
/
stabily.api.txt
54 lines (48 loc) · 2.41 KB
/
stabily.api.txt
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
console.log(upload[0].imagePath)
// 2d
//
// const engineId = 'stable-diffusion-xl-beta-v2-2-2';
// const apiHost = 'https://api.stability.ai';
// // const apiKey = process.env.STABILITY_API_KEY;
// // const apiKey = "sk-ZrK2fwIkX81k0J42un7Hnchxa91TP85dj1XHUpntlfkbxzPr";
// const apiKey = "sk-3gXaI8vWnyebkRYah3sl9NhNc7GLrs8G9N1lk2DKVKOW5NQA";
// // const apiKey = "3";
// if (!apiKey) throw new Error('Missing Stability API key.');
// const formData = new FormData();
// formData.append('init_image', fs.readFileSync(`${upload[0].imagePath}`));
// formData.append('init_image_mode', 'IMAGE_STRENGTH');
// formData.append('image_strength', 0.85);
// formData.append('text_prompts[0][text]', '2d');
// formData.append('cfg_scale', 7);
// formData.append('clip_guidance_preset', 'FAST_BLUE');
// formData.append('style_preset', 'anime');
// formData.append('samples', 1);
// formData.append('steps', 30);
// fetch(`${apiHost}/v1/generation/${engineId}/image-to-image`, {
// method: 'POST',
// headers: {
// ...formData.getHeaders(),
// Accept: 'application/json',
// Authorization: `Bearer ${apiKey}`,
// },
// body: formData,
// })
// .then((response) => {
// if (!response.ok) {
// console.log(response.body)
// console.log(response.statusText)
// console.log(response.url)
// throw new Error(`Non-200 response: ${response.status} - ${response.statusText}`);
// }
// return response.json();
// })
// .then((responseJSON) => {
// responseJSON.artifacts.forEach((image, index) => {
// fs.writeFileSync(`public/Results/${index}.png`, Buffer.from(image.base64, 'base64'));
// alert("succesful request")
// });
// })
// .catch((error) => {
// console.error('Error:', error);
// });
//2d