Skip to main content
POST
cURL

Which models accept this

Only models that declare the text-completion capability. Everything else returns MODEL_CAPABILITY_UNSUPPORTED, because answering a raw-prompt request on a model shaped for conversation produces output that looks fine and is not what you asked for. Most models here are chat models. If you are starting something new, use chat completions — this endpoint exists so that code written against the older shape keeps working.

One prompt per call

prompt takes a string, or an array holding exactly one string. Several prompts in one call are rejected rather than partly answered.

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

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.

prompt
required

The text to continue. A string, or an array holding exactly one string -- several prompts in one call are rejected rather than partly answered.

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
temperature
number

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

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

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

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.

n
integer

How many completions to return.

Not supported. Sending it returns INVALID_REQUEST.

best_of
integer

Sample several completions server-side and return the best one.

Not supported. Sending it returns INVALID_REQUEST.

logprobs
integer

Per-token log probabilities.

Not supported. Sending it returns INVALID_REQUEST.

echo
boolean

Repeat the prompt back at the start of the completion.

Not supported. Sending it returns INVALID_REQUEST.

suffix
string

Text that should follow the completion (fill-in-the-middle).

Not supported. Sending it 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: "text_completion"
created
integer
required
model
string
required
choices
object[]
required
usage
object
required
system_fingerprint
string