Streaming

Read output while the model is still generating.

Enable streaming

Add stream: true to a chat-completion request. The response uses server-sent events. Each chunk can contain a text delta, a tool-call delta, or usage information.

Python
stream = client.chat.completions.create(
    model="glm-5.3-uncensored",
    messages=[{"role": "user", "content": "Tell me a story."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices:
        print(chunk.choices[0].delta.content or "", end="", flush=True)

Event format

SSE · example
data: {"choices":[{"delta":{"content":"Hello"}}]}

data: {"choices":[{"delta":{"content":" there."}}]}

data: [DONE]

Completion and cancellation

Stop reading when the stream finishes. Closing the request cancels forwarding. An interrupted stream may contain partial output; do not treat it as a completed response.

Policy and streaming

When an output policy is active, the gateway may hold a short output window for evaluation. Content already delivered to the client cannot be retracted.

Availability depends on your connected provider. Check service status and keep x-request-id with your diagnostics.