File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change 3
3
//An example to generate an image and save to a file
4
4
5
5
import Together from 'together-ai' ;
6
- import fs from 'fs' ;
7
6
8
7
const together = new Together ( ) ;
9
8
10
9
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 ,
16
15
} ) ;
17
16
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 ) ;
21
18
22
- const buffer = Buffer . from ( image_data , 'base64' ) ;
23
- fs . writeFileSync ( 'image.jpg' , buffer , { encoding : 'base64' } ) ;
24
- }
19
+ // console.log(response.data[0]?.url);
25
20
}
26
21
27
22
main ( ) ;
You can’t perform that action at this time.
0 commit comments