Skip to main content

POST /v1/completions

Creates a completion for the given prompt and model.

Request body

string
required
The model ID to use. See the models page for available models.Example: openai/gpt-oss-120b
string
required
The prompt to generate a completion for.
integer
Maximum number of tokens to generate. Defaults to the model’s maximum.
number
Sampling temperature between 0 and 2. Defaults to 1.
number
Nucleus sampling parameter. Defaults to 1.
boolean
If true, responses are sent as server-sent events. Defaults to false.
string | array
Up to 4 sequences where the model will stop generating.

Example request

Example response

Streaming

Set stream: true to receive responses as server-sent events.