JavaScript & TypeScript
Stream Object
Learn how to stream structured objects using the JavaScript SDK.
Overview
The streamObject
method allows you to stream structured objects from your workflows using a Zod or JSON schema. This is useful when you want to consume structured data as it is being generated, providing a more interactive user experience.
Usage
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. |
schema | ZodType /JsonSchema | The Zod or JSON schema describing the expected object structure. |
Return Value
The streamObject
method returns the following object:
Error Handling
All errors thrown by the SDK extend from the base ItzamError
class. See Error Handling for details.
Inspecting Runs
You can use the runId
from the response metadata to fetch more details about the run using getRunById
.