stream: true to receive standard chat.completion.chunk SSE, terminated by data: [DONE]. Because agent turns can run for minutes, streaming is the recommended mode for every integration — a stream is unambiguous about liveness where a long POST is not.
What the stream contains
- An immediate first chunk (
delta: {"role": "assistant", "content": ""}) — fast first byte even while the agent environment spins up. - SSE comment lines (
: keepalive) during silent agent work. Every OpenAI SDK ignores them per the SSE spec — but don’t buffer the stream through proxies that time out on first-byte silence. - One or more
delta.contentchunks carrying the reply. - The final chunk with
finish_reason— always carries thex_ravchatblock, even withoutstream_options. - With
stream_options.include_usage— one extra chunk before[DONE]withchoices: []and populatedusage(includingusage.cost). All other chunks carryusage: null.
In v1 the reply currently arrives as a single content chunk (whole-message), not token-by-token; finer-grained incremental deltas are a planned fast-follow. Write your client to consume any number of
delta.content chunks — as every OpenAI SDK already does — and rely on finish_reason (not chunk count) for completion. Nothing changes when incremental deltas land.Reading credits from a stream
Streaming responses can’t carryusage.cost in a header — headers are sent before the turn runs. Read credits from the final chunk’s x_ravchat.credits or from the include_usage usage chunk.