Completions
POST
Generate text continuations from one or more prompts. Best for simple text generation, autocomplete, and single-turn tasks.
Image inputs, structured chat messages, reasoning controls, structured outputs, and tools require Chat Completions.
Request
Headers
string
The media type of the request body.Possible values:
application/json, application/vnd.msgpackDefault: application/jsonSee Payload Optimization for details.string
The compression encoding applied to the request body.Possible values:
gzipWhen set, the request body must be gzip-compressed. Can be combined with any supported Content-Type.See Payload Optimization for details.Body
string | array
required
The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.
string
required
The model to use for completion. See Supported Models for a list of available models.
boolean | null
Streams partial completion data as data-only server-sent events as tokens become available. The stream ends with a
data: [DONE] message.Default: falseboolean | null
Returns raw tokens instead of text.Default:
falseinteger | null
The maximum number of tokens that can be generated in the completion. The total length of input tokens and generated tokens is limited by the model’s context length.Default:
nullinteger | null
The minimum number of tokens to generate for a completion. If not specified or set to 0, the model will generate as many tokens as it deems necessary. Setting to -1 sets to max sequence length.Default:
nullinteger | null
Makes a best effort to sample deterministically so repeated requests with the same
seed and parameters return the same result. Determinism is not guaranteed.Default: nullstring | array | null
Up to four sequences that cause the API to stop generating further tokens. The returned text does not contain the stop sequence.Default:
nullnumber | null
Sampling temperature between 0 and 2. Higher values, such as 0.8, make output more random; lower values, such as 0.2, make it more focused and deterministic. We recommend changing either this value or
top_p, but not both.Constraints: min: 0, max: 2Default: 1number | null
Nucleus sampling parameter between 0 and 1. The model considers only tokens comprising the top
top_p probability mass. For example, 0.1 means only tokens comprising the top 10% probability mass are considered. We recommend changing either this value or temperature, but not both.Constraints: min: 0, max: 1Default: 1boolean
Returns the prompt in addition to the completion. This parameter is incompatible with
return_raw_tokens: true.Default: falsestring | null
A unique identifier representing your end-user, which can help Cerebras to monitor and detect abuse.Default:
nullstring | null
An opaque identifier that groups related requests so they reuse the same prompt cache. Requests sharing the same
prompt_cache_key are routed together, which increases cache hits and reduces time to first token.Set it to a stable conversation, session, or workflow ID.Maximum length: 1024 characters.Default: nullinteger | null
Returns log probabilities of the output tokens.For example, if
logprobs is 5, the API returns the five most likely tokens. The API always returns the log probability of the sampled token, so there may be up to logprobs + 1 elements in the response.Constraints: min: 0, max: 20Default: nullSetting
logprobs to 0 is different from setting it to null. A value of null disables log probabilities. A value of 0 returns the sampled token’s log probability without alternative token log probabilities.Completion Response
object[]
required
The list of completion choices the model generated for the input prompt.
integer | null
required
The Unix timestamp (in seconds) of when the completion was created.
string
A unique identifier for the completion.
string
The model used for completion.
string
required
The object type, which is always
text_completion.string
Identifies the backend configuration used by the model. Use it with the
seed request parameter to determine whether backend changes might affect determinism.object
Usage statistics for the completion request.
object
Performance timing information for the request.

