Enable streaming
Confirm the selected profile declares stream, then set "stream":true. Use cURL --no-buffer to display events promptly. Credentials, profile UUID, budget and price version are the same as for a non-streaming request.
The response is text/event-stream. Events are separated by blank lines; combine multiple data: lines within an event. Network reads can split UTF-8 characters and events, so a socket chunk is not a complete JSON message.
OpenAI format
Simplified illustrative events:
data: {"choices":[{"index":0,"delta":{"content":"Hello"}}]}
data: {"choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
Accumulate choices[].delta.content and merge tool-call fragments by index/ID. Require the normal protocol terminal signal, not merely a closed connection. Usage availability and location depend on the model; missing usage is not zero usage.
Anthropic format
event: message_start
data: {"type":"message_start","message":{"role":"assistant","content":[]}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
event: message_stop
data: {"type":"message_stop"}
This is an excerpt, not the full event sequence. Clients must also handle the selected model’s content_block_start/stop, message_delta, tool-input fragments and other events. Use message_stop for normal message completion, not OpenAI [DONE].
Errors, cancellation and costs
| Event | Action |
|---|---|
| Non-2xx before streaming begins | Read the protocol error and retain request IDs |
Comments such as : keep-alive | Keepalive only, not generated output |
| Error after the stream begins | Mark failure or pending reconciliation; HTTP 200 is insufficient |
| Cancel, disconnect or missing normal terminal | Keep delivered output and query the original request; do not auto-repeat |
| Normal protocol terminal | Output is complete; settlement still follows the original consumption record |
Cancelling after partial output does not guarantee a full refund. Inspect My requests and Billing. Agent Run has its own event contract; this is not a universal WebSocket/SSE promise.