BUILD WITH INFERMAX
Streaming
Receive Chat Completions as Server-Sent Events.
Enable the stream
shell
curl -N "$INFERMAX_API_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $INFERMAX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"<entitled-model-id>","messages":[{"role":"user","content":"Say hello."}],"stream":true,"stream_options":{"include_usage":true},"max_completion_tokens":64}'Parse complete SSE events, not network chunks. Accumulate choices[].delta, inspect finish_reason, and stop at data: [DONE]. Usage may arrive in a final event; do not infer zero when it is absent.
SSE · abbreviated illustration
data: {"choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: [DONE]
A disconnected stream can leave dispatch uncertain. Inspect request state or receipt before retrying with the same idempotency key. See retry rules and the complete contract.