Back to feed

v1.4.0

Nov 17, 2025
Replicate/Replicate JS SDKAPIv1.4.0

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.

import Replicate from "replicate";
import * as fs from "node:fs/promises";

const replicate = new Replicate();
const input = {
  prompt: "black forest gateau cake spelling out the words \"FLUX SCHNELL\", tasty, food photography, dynamic shot"
};

let index = 0;
for await (const event of replicate.stream("black-forest-labs/flux-schnell", { input })) {
  if (event.event === "output") {
      await fs.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.

import Replicate from "replicate";
const replicate = new Replicate();

const input = {
  prompt: "black forest gateau cake spelling out the words \"FLUX SCHNELL\", tasty, food photography, dynamic shot"
};

let index = 0;
for await (const event of replicate.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: https://github.com/replicate/replicate-javascript/compare/v1.3.1...v1.4.0