/v1/completions endpoint takes a raw text prompt and returns one or more generated continuations. Unlike the chat endpoint, there is no message array or role structure — you supply a prompt string and the model completes it. This format is well-suited for single-turn tasks such as summarization, extraction, code generation, and template-based workflows.
Endpoint
Request Parameters
The ID of the model to use. Call
GET /v1/models to retrieve the list of models available to your account.The prompt(s) to complete. Pass a single string for one prompt or an array of strings to batch multiple prompts in a single request.
The maximum number of tokens to generate per completion. Defaults to the model’s context limit. Use this to cap response length and manage costs.
Sampling temperature between
0 and 2. Higher values produce more varied output; lower values produce more deterministic output. Defaults to 1. Avoid combining with top_p.Nucleus sampling threshold between
0 and 1. The model samples from the smallest token set whose cumulative probability exceeds this value. Defaults to 1. Avoid combining with temperature.When
true, the API streams token deltas as server-sent events and sends a final [DONE] message. Defaults to false.One or more sequences at which generation stops. Pass a single string or an array of up to four strings.
The number of independent completions to generate for each prompt. Defaults to
1. Note that generating multiple completions increases token usage proportionally.