Docs / API reference
Streaming
Streaming uses SSE by default, with the same chunk structure as the official API.
PYTHON
stream = client.chat.completions.create(
model="deepseek-v4",
messages=[{"role": "user", "content": "Write a short intro"}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")A few details
- usage arrives only in the final chunk, so pass stream_options to receive it.
- If upstream drops the stream, the gateway will not silently fill in the gap — it ends with an error event; retry on the client side.
- Time to first token is measured when the edge node receives the first chunk, and is visible per request in the usage logs.
Requests that produce no output for an extended period are closed by the gateway after 10 minutes.