Stream HelpersCohereStream
CohereStream
The CohereStream function is a utility that transforms the output from Cohere's API into a ReadableStream. It uses AIStream under the hood, applying a specific parser for the Cohere's response data structure. This works with the official Cohere API, and it's supported in both Node.js, the Edge Runtime, and browser environments.
Import
React
import { CohereStream } from "ai"
Parameters
response:
The response object returned by a call made by the Provider SDK.
callback?:
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.
Returns
A ReadableStream.