Enabling Streaming
To receive a streaming response, setstream: true in the request body of the chat or retry endpoints:
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | The user message to send to the agent. |
stream | boolean | No | Stream the response as SSE. Defaults to true. |
conversationId | string | No | Continue an existing conversation. Omit to create a new one. |
userId | string | No | Associate a user with a new conversation. Max 128 chars, [a-zA-Z0-9._-] only. Ignored when conversationId is provided. |
Once set, a conversation’s
userId is immutable — it cannot be changed or removed. See User Conversations for details on managing per-user conversation history.Content-Type: text/event-stream and follows the AI SDK v5 UI Message Stream protocol, indicated by the x-vercel-ai-ui-message-stream: v1 header.
Event Types
The stream emits newline-delimited JSON events. Each event has atype field:
start
Emitted once at the beginning of the stream. Contains the message ID.
text-delta
Emitted for each chunk of generated text. Concatenate all deltas to build the full response.
finish
Emitted once when generation is complete. Contains metadata including the conversation ID, user ID, and credit usage.
Code Examples
Non-Streaming Mode
Whenstream is set to false, the API returns a standard JSON response with the complete message: