Uh oh!
There was an error while loading. Please reload this page.
This is a bug-fix release that fixes the behavior of replicate.stream() when dealing with models that output files. By default the event.data will be a FileOutput instance that can be written to disk.
importReplicatefrom"replicate";import*asfsfrom"node:fs/promises";constreplicate=newReplicate();constinput={prompt: "black forest gateau cake spelling out the words \"FLUX SCHNELL\", tasty, food photography, dynamic shot"};letindex=0;forawait(consteventofreplicate.stream("black-forest-labs/flux-schnell",{ input })){if(event.event==="output"){awaitfs.writeFile(`my-image-${index++}.png`,event.data);}}The stream() method also now supports the useFileOutput option which, when false, will output the HTTP or data URL directly.
importReplicatefrom"replicate";constreplicate=newReplicate();constinput={prompt: "black forest gateau cake spelling out the words \"FLUX SCHNELL\", tasty, food photography, dynamic shot"};letindex=0;forawait(consteventofreplicate.stream("black-forest-labs/flux-schnell",{ input,useFileOutput: false})){if(event.event==="output"){console.log("URL:",event.data);}}What's Changed
New Contributors
Full Changelog: v1.3.1...v1.4.0