Enabling Streaming
To receive a streaming response, setstream: true in the request body of the chat or retry endpoints:
Request Body
string
The user message to send to the agent. Omit to continue the conversation after submitting a client action result.
boolean
default:true
Stream the response as SSE. Defaults to
true.string
Continue an existing conversation. Omit to create a new one.
string
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 UIMessage Stream protocol. Events are newline-delimited JSON, where each line is a JSON object with a type field.
Event Types
- Text Events
- Client Action Events
- Step & Completion Events
Metadata
Thefinish event is accompanied by a message-metadata event containing Chatbase-specific metadata:
string
required
Unique ID of the assistant message.
string
required
The ID of the user message that triggered this response. For continuation responses, this is the last user message in the conversation.
string
required
The conversation ID. Use this for follow-up messages.
string | null
required
The user ID associated with this conversation, or
null if none.string
required
Why the model stopped generating:
"stop"— normal completion"error"— an error occurred"tool-calls"— the agent invoked a client action — submit the result and continue
object
required
data: [DONE].
Code Examples
Non-Streaming Mode
Whenstream is set to false, the API returns a standard JSON response with the complete message:
- Text Response
- Client Action Response
