Streaming
Receive assistant responses as server-sent events.
Streaming
Set "stream": true on message requests to receive a text/event-stream response.
First-message stream
POST /v1/messages emits public_api_conversation before forwarding upstream content events.
Request body
{
"message": "Summarize FHA gift fund rules.",
"user": {
"external_user_id": "user_123"
},
"stream": true
}SSE response
data: {"type":"public_api_conversation","request_id":"req_9b8f0b5fcb5b4eaa","conversation_id":"conv_3c2fd2bcf41f4f12","conversation_created":true}
data: {"type":"content","content":"Gift funds are generally allowed with "}
data: {"type":"content_postprocessed","content":"Gift funds are generally allowed with documentation."}
data: {"type":"complete","metadata":{"tokensUsed":123}}
data: {"type":"public_api_complete","request_id":"req_9b8f0b5fcb5b4eaa","conversation_id":"conv_3c2fd2bcf41f4f12","message_id":"msg_1fecc99b7f334e6c"}
Existing-conversation stream
POST /v1/conversations/{conversationId}/messages skips the initial conversation event and ends with public_api_complete.
SSE response
data: {"type":"content","content":"The conversation can continue using the existing ID."}
data: {"type":"complete","metadata":{"tokensUsed":88}}
data: {"type":"public_api_complete","request_id":"req_9b8f0b5fcb5b4eaa","conversation_id":"conv_3c2fd2bcf41f4f12","message_id":"msg_1fecc99b7f334e6c"}
Important behavior
- Streaming requests do not support
Idempotency-Key - Upstream content events are passed through as the service receives them
- The API appends a terminal
public_api_completeevent after the assistant message is stored