ReplicateStream
ReplicateStream has been removed in AI SDK 4.0.
ReplicateStream is part of the legacy Replicate integration. It is not compatible with the AI SDK 3.1 functions.
The ReplicateStream function is a utility that handles extracting the stream from the output of Replicate's API. It expects a Prediction object as returned by the Replicate JavaScript SDK, and returns a ReadableStream. Unlike other wrappers, ReplicateStream returns a Promise because it makes a fetch call to the Replicate streaming API under the hood.
Import
React
import { ReplicateStream } from "ai"API Signature
Parameters
pre:
Prediction
callbacks?:
AIStreamCallbacksAndOptions
AIStreamCallbacksAndOptions
onStart:
() => Promise<void>
onCompletion:
(completion: string) => Promise<void>
onFinal:
(completion: string) => Promise<void>
onToken:
(token: string) => Promise<void>
options:
{ headers?: Record<string, string> }
Returns
A ReadableStream wrapped in a promise.