JavaScript & TypeScript
Stream Text
Learn how to stream text responses using the JavaScript SDK.
Overview
The streamText
method allows you to stream text responses from your workflows. This is useful when you want to show the response as it’s being generated, providing a better user experience.
Usage
To consume the stream, you can use it like this:
You can also get the metadata of the run once the stream is finished:
Parameters
Parameter | Type | Description |
---|---|---|
input | string | The input text to generate a response for. |
workflowSlug | string | The slug of the Workflow to use for generation. |
groupId | string | Optional. Identifier for grouping related runs. |
Return Value
The streamText
method returns the following object: