Skip to main content
Use a current public model ID from Models or GET /models. Example IDs and options must match the selected model’s advertised capabilities and limits.
Set "stream": true to receive the completion as server-sent events, token by token, in the standard OpenAI chunk format.

Enabling streaming

The chunk stream

The response is text/event-stream. Each event is a chat.completion.chunk object, and the stream ends with data: [DONE]:
  • Reasoning tokens arrive as delta.reasoning_content, interleaved before the answer. See Reasoning.

Usage and cost on streams

Pass "stream_options": {"include_usage": true} and the final data chunk before [DONE] has an empty choices array and carries the totals:
nomask.cost_usd is the exact USD amount charged to your balance for the request, the same figure GET /usage will show. Confirmed cached input and frozen savings are included in the usage metadata. See Prompt Caching for the response fields and billing rules.

Errors mid-stream

If the model fails after the stream has started, you receive a final chunk containing an error object in the standard envelope, then [DONE]. Errors before any tokens are sent return a normal JSON error response with the right HTTP status instead.

Disconnects and billing

Billing settles when the request finishes on the server. If your client disconnects mid-stream, the tokens generated up to that point are still billed; when exact usage is unavailable for an interrupted stream, token counts are estimated and the usage record is flagged with tokens_estimated: true.