The flow
1
Create or pick a conversation
Create one against an agent (
agent_id from List agents):2
Open the event stream
Attach to the stream so you don’t miss early events:
-N disables buffering so events print as they arrive.3
Post a message
Reading the stream
Each event has a name, anid: cursor, and a one-line JSON payload:
text_delta chunks to the active reply; final (or error) ends the turn. The full event vocabulary and scope rules are on Stream conversation events.
In JavaScript
EventSource can’t set an Authorization header, so read the stream with fetch and a streaming body reader (works in Node 18+ and modern browsers):
Tips
- Open the stream early — attach before or right after posting so you catch the first
text_delta. - One stream, many turns —
result/errorends a turn, not the stream. Keep it open and post again for the next turn. - Stop a running turn with Interrupt the active turn.