stream: true to receive server-sent events. The OpenAI SDK parses events for you.
Chat completion stream
include_usage: true for all chat streams, even when the caller omits it or sets it to false. A usage chunk can have an empty choices array. Always check that a choice exists before reading its delta.
At the wire level, events are data: {JSON} records separated by a blank line. Chat streams normally terminate with data: [DONE]. Network chunks do not necessarily align with event boundaries; use the SDK or a proper SSE parser.
DeepSeek reasoning deltas
Withreasoning_effort: "high" (or another supported thinking level), DeepSeek sends reasoning in choices[0].delta.reasoning_content and the answer in choices[0].delta.content. Append each to a separate display. A chunk may contain only one of these fields, and reasoning can arrive before answer text. Both count toward the output-token budget.
The Playground displays these separately and retains received partial content after Stop. See reasoning for JSON responses and conversation replay.
Responses stream
The Responses endpoint emits typed events. See stateless Responses for a complete example. Do not parse Responses events as chatchoices chunks.
Handle interruption
When the gateway observes your client disconnect, it cancels generation. The backend may already have processed part of it. Test cancellation through your deployed client and proxy path: closing the local stream alone does not prove that the disconnect reached the gateway.- A final usage event may be absent after interruption. Missing token counts remain unknown in Activity.
- HTTP
200indicates that a stream started; it does not prove the full generation completed. - A failed stream can retain partial text. Decide whether your application should display, discard, or label it.
- Do not replay a partial request automatically without considering duplicate generation and charges.