[DONE] sentinel.
Request
Set"stream": true. Streams include the terminal usage chunk by default, including when stream_options is omitted. Send "stream_options": {"include_usage": false} to omit usage from the stream; Particle still meters the request.
Chunk anatomy
Requests usingparticle-1 return particle-ai/particle-1 in the chunks’ model field.
text/event-stream
- Every chunk carries the same
id,created, andmodel— including keep-alives and the usage chunk (which has an emptychoicesarray). - Reasoning arrives first as
delta.reasoning_content; visible text follows asdelta.content. - The terminal content chunk has an empty
deltaand the finalfinish_reason. data: [DONE]is always the last line on a successful stream.
Keep-alives
Reasoning models can pause for tens of seconds between tokens. Idle streams get killed by intermediaries, so the gateway injects traffic after 15 seconds of upstream silence:- Before the first upstream event (e.g. while capacity is being confirmed or your request waits in the priority queue): an SSE comment line —
: keep-alive. - After the stream has started: a real, spec-compliant
chat.completion.chunkwith the stream’s ownid/created/model, an emptydelta, and"finish_reason": null— safe for strict parsers, invisible to UIs.
finish_reason values
Matched stop details
choices[i].matched_stop provides optional details about what stopped generation. It can appear in Chat Completions and Completions responses for both DeepSeek V4.1 Flash and GLM 5.3 Flash:
- Streaming: alongside
finish_reasonon the terminal choice chunk. - Non-streaming: alongside
finish_reasonin each choice.
Use
finish_reason to distinguish normal termination, token-limit termination, and tool calls. The Responses WebSocket API does not expose matched_stop.
Repetition wall
When output becomes highly repetitive, Particle may end the stream withfinish_reason: "length". You receive the output generated so far, a well-formed terminal chunk, usage, and [DONE]. Treat length mid-conversation as a signal to re-prompt rather than an error.
JSON output failures
Forresponse_format: {"type":"json_object"}, a final text answer must be a valid JSON object or array. Reasoning is not a substitute for that answer. If generation stops normally but the final content is empty or invalid, the stream ends with:
finish_reason: "stop" or [DONE] follows. HTTP remains 200 because the stream has already started; handle the top-level error even when the HTTP status is successful. Discard any partial answer received before the error.
Token-limit termination remains finish_reason: "length", followed by usage and [DONE]. Its content may be empty or incomplete JSON; treat it as truncation, not a valid final answer. Tool-call completions retain their existing behavior. Final-content validation is bounded to 16 MiB per response; a normally stopped response exceeding that limit also returns invalid_model_output. Generated tokens remain metered, including when final-output validation fails.
Disconnects and billing
- Client disconnects propagate upstream. Closing the connection stops generation promptly and frees capacity for other requests.
- Billing follows generation, not delivery. Tokens the model produced before your disconnect are metered and billed.
- Mid-stream failures (e.g. usage pipeline unavailable) surface as an SSE error event — the stream ends with an error object and no
[DONE], so clients can distinguish “complete” from “failed” structurally. - Retries: if you never received
[DONE], the stream did not complete — resubmitting the request is safe and idempotent on your side (a fresh completion is generated and billed).
Client checklist
- Parse with a permissive SSE reader; ignore empty deltas and
: commentlines. - Accumulate
delta.reasoning_contentanddelta.contentseparately. - Wait for
[DONE]to confirm stream completion. Separately validate the final content or tool calls your application requires;[DONE]alone does not guarantee a usable answer. - Surface
finish_reason: "length"to users as truncation.