v1.0.0-beta.1
Pre-release
Pre-release
The latest release of replicate contains breaking changes. The replicate.run() method will now return FileObjects rather than URLs by default for models that output files.
The FileObject implements a ReadableStream to make it easier to work with files and ensures that Replicate can deliver file data to the client in the most efficient manner possible.
For example:
const [output] = await replicate.run("black-forest-labs/flux-schnell", {
input: { prompt: "astronaut riding a rocket like a horse" }
});
// To access the file URL:
console.log(output.file()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output);
// To stream the file back to a browser:
return new Response(output);
// To read the file in chunks:
for await (const chunk of output) {
console.log(chunk); // UInt8Array
}In case of breakage, in most instances, updating existing applications to call output.url() should fix issues.
To revert to previous behaviour you can opt out of FileOutput by passing useFileOutput: false to the Replicate constructor.
const replicate = new Replicate({ useFileOutput: false });Change log
- BREAKING Enable FileObject and blocking mode by default f00f51d