Skip to main content
Server-sent events in the standard OpenAI chunk format — with keep-alives so long thinking pauses never look like a dead connection. This page covers HTTP Chat Completions and Completions streaming. To send new user input while generation is running, use mid-turn steering over the Responses WebSocket API. That transport uses JSON events and ping/pong frames, not SSE chunks or a [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 using particle-1 return particle-ai/particle-1 in the chunks’ model field. text/event-stream
  • Every chunk carries the same id, created, and model — including keep-alives and the usage chunk (which has an empty choices array).
  • Reasoning arrives first as delta.reasoning_content; visible text follows as delta.content.
  • The terminal content chunk has an empty delta and the final finish_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.chunk with the stream’s own id/created/ model, an empty delta, 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_reason on the terminal choice chunk.
  • Non-streaming: alongside finish_reason in 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 with finish_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

For response_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:
The error frame ends with a blank line. No successful 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 : comment lines.
  • Accumulate delta.reasoning_content and delta.content separately.
  • 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.