ReplicateStream function is a utility that handles extracting the stream from the output of Replicate's (opens in a new tab) API.
It expects a
Unlike other wrappers,
ReplicateStream returns a
Promise because it makes a
fetch call to the Replicate streaming API (opens in a new tab) under the hood.
This optional parameter can be an object containing callback functions to handle the start, each token, and completion of the AI response. In the absence of this parameter, default behavior is implemented.
See our Replicate Guide for examples.