Skip to content

Commit a67a931

Browse files
authored
Merge pull request #178 from togethercomputer/Nutlope-patch-1
Update image.ts
2 parents c92d34b + 9ed9add commit a67a931

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

examples/image.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,20 @@
33
//An example to generate an image and save to a file
44

55
import Together from 'together-ai';
6-
import fs from 'fs';
76

87
const together = new Together();
98

109
async function main() {
11-
//Request the image generation
12-
const image = await together.images.create({
13-
model: 'runwayml/stable-diffusion-v1-5',
14-
prompt: 'space robots',
15-
n: 1,
10+
// Request the image generation
11+
const response = await together.images.create({
12+
prompt: 'a flying cat',
13+
model: 'black-forest-labs/FLUX.1-schnell',
14+
steps: 4,
1615
});
1716

18-
//Write the image to a file
19-
if (image.data && image.data[0] && image.data[0].b64_json) {
20-
let image_data = image.data[0].b64_json;
17+
console.log(response);
2118

22-
const buffer = Buffer.from(image_data, 'base64');
23-
fs.writeFileSync('image.jpg', buffer, { encoding: 'base64' });
24-
}
19+
// console.log(response.data[0]?.url);
2520
}
2621

2722
main();

0 commit comments

Comments
 (0)