Skip to main content
POST
cURL

Streaming

With stream: true the response is text/event-stream: one data: event per chunk, terminated by data: [DONE]. The last data event carries usage whether or not you sent stream_options.include_usage — you never have to choose between streaming and knowing what you were billed. If a stream fails partway, chunks already sent are not withdrawn. You get one more event carrying an error object, then [DONE]. Treat a stream that ended without [DONE] as incomplete.

Token accounting

The usage object is the number you are billed on, not an estimate of it. When a stream is cancelled after the model has begun producing output, those tokens are still billed — see Errors for the two codes where that happens.

Authorizations

Authorization
string
header
required

Authorization: Bearer <your API key>. On /v1/messages, the Anthropic-style x-api-key: <your API key> header is accepted instead.

Headers

Idempotency-Key
string

Your own key for making a retry safe (up to 255 characters). It is accepted and echoed back today; de-duplication of replays arrives in a later release, so a retry is currently a second billable call.

Maximum string length: 255
x-session-affinity
string

Only used with model auto or auto-open: send the same value on every turn of one conversation and the platform keeps it on the same model where it can. Takes precedence over prompt_cache_key; without either, the conversation is recognised by how it began.

Maximum string length: 256

Body

application/json
model
string
required

Which model answers the call. A bare slug for platform models (deepseek-v4.1-flash), or a full resource name for something your account owns (accounts/{account}/models/{model}, or a deployment). Never an upstream vendor's own name. auto (Prentis One) asks the platform to choose the model for each call; auto-open (Prentis One Open) chooses among open-weight models only, and on hard questions has three of them answer and keeps the best answer. auto:[,...] or auto-open:[,...] limits the choice to the models you list. auto-open sets each model's reasoning effort itself and ignores reasoning_effort, reasoning and thinking. Both are rolling out gradually; see Prentis One.

Maximum string length: 256
messages
object[]
required

The conversation so far, oldest first. Each turn carries a role (system, user, assistant or tool) and its content.

Minimum array length: 1
stream
boolean
default:false

Return the answer as server-sent events as it is generated, instead of one response at the end. The last data event carries the usage numbers either way.

stream_options
object

Streaming options. include_usage is accepted for compatibility; usage arrives on the final event whether or not you ask for it.

max_tokens
integer

Ceiling on how many tokens may be generated. Omit it to use the model's own default.

Required range: x >= 1
max_completion_tokens
integer

Ceiling on generated tokens. Wins over max_tokens when both are sent.

Required range: x >= 1
temperature
number
default:1

How much randomness to allow when picking each token. Lower is more repeatable, higher is more varied.

Required range: 0 <= x <= 2
top_p
number
default:1

Nucleus sampling: only consider the most likely tokens up to this share of the probability mass. Tune this or temperature, not both.

Required range: 0 <= x <= 1
stop

Up to 4 strings that end generation as soon as the model produces one. The matched string is not included in the output.

seed
integer

Best effort repeatability: the same seed with the same parameters returns the same answer on models that support it.

frequency_penalty
number
default:0

Pushes the model away from tokens it has already used often in this answer. Negative values do the opposite.

Required range: -2 <= x <= 2
presence_penalty
number
default:0

Pushes the model away from tokens that have appeared at all in this answer, which tends to move it on to new ground.

Required range: -2 <= x <= 2
user
string

Your own identifier for the end user behind the call. It is echoed back in this request's log line so you can correlate the two; it is not kept on the usage record.

Maximum string length: 256
prompt_cache_key
string

Only used with model auto or auto-open: a key that marks calls as one conversation, so the platform keeps them on the same model. It is not passed on to any provider.

Maximum string length: 256
tools
object[]

Function definitions the model may call. If none of the providers that can serve this model support tools, the call is rejected rather than answered as though you had not asked.

tool_choice

Whether the model may, must, or must not call a tool: none, auto, required, or one named function.

Available options:
none,
auto,
required
response_format
object

Ask for free text, a JSON object, or JSON matching a schema. Rejected if no provider behind this model can honour it.

service_tier
enum<string>
default:standard

Which service tier serves the call. Only standard is accepted today.

Available options:
standard,
priority,
fast
reasoning_effort
enum<string>

Ask for the model's reasoning at this effort: minimal, low, medium, high, xhigh or max. A model that has fewer levels uses the nearest one at or below the one asked (minimal counts as low). Only models that reason accept it; the reasoning comes back in reasoning_content and its tokens are counted in completion_tokens. none is accepted, and changes nothing, on a model that does not reason; a model that reasons cannot promise to stop, so it refuses none. Ignored with model auto-open.

Available options:
none,
minimal,
low,
medium,
high,
xhigh,
max
reasoning
object

Ask for the model's reasoning. effort takes the same values as reasoning_effort, up to xhigh and max; an object without effort asks for medium. Only models that reason accept it. Ignored with model auto-open.

include_reasoning
boolean

An older way to ask for reasoning, kept for clients that still send it. false leaves the reasoning out of the response, though the model still reasons and those tokens are still counted in completion_tokens; true asks for reasoning on a model whose reasoning can be switched on or set to a level, and changes nothing on any other model.

n
integer

How many completions to return.

Only 1 is accepted. Any other value returns INVALID_REQUEST.

logprobs
boolean

Per-token log probabilities.

Only false is accepted. true returns INVALID_REQUEST.

Response

OK. With stream: true the same call answers text/event-stream instead, one chunk per event, terminated by data: [DONE]; the last data event carries usage whether or not you asked for it.

id
string
required
object
string
required
Allowed value: "chat.completion"
created
integer
required
model
string
required
choices
object[]
required
usage
object
required
system_fingerprint
string