Skip to main content
Streaming and non-streaming requests take the same wall-clock time to finish, the difference is when you start seeing output. For anything user-facing, streaming turns seconds of blank waiting into immediate feedback, and for reasoning models it lets you show the thinking phase while the final answer is still forming. Set stream: true:

What’s on the wire

A streamed response is server-sent events: data: lines, each carrying a JSON chunk, terminated by a literal data: [DONE]. The SDKs parse this for you; it only matters when you consume the HTTP stream yourself:
  • Each chunk carries a delta, the increment since the previous chunk: content text, reasoning on reasoning models, or tool_calls fragments when the model is composing a tool call.
  • The final content chunk carries finish_reason (stop, length, or tool_calls); concatenating every delta reproduces exactly the message a non-streamed call would have returned.

Streaming a reasoning model

With a reasoning model (GLM-5.3, DeepSeek V4 Pro, or GLM-5.3 Flash), read both delta fields, thinking arrives in reasoning before the answer arrives in content:

Detecting incomplete streams

Once streaming begins, the HTTP status is already sent, a mid-generation failure ends the stream rather than delivering an error object. Treat a stream that closes without a finish_reason (or, on the raw wire, without [DONE]) as an incomplete response: keep the partial text if partial output is useful, otherwise retry the request.
Set max_tokens deliberately and watch for finish_reason: "length", a truncated stream looks exactly like a finished one to a user unless you check.