Text Completions
Prompt-style completion endpoint for base / instruct text models. Use this when your model has type text; for conversational models, use Chat Completions instead.
POST
/v1/completionsRequest body
📋Request
1{
2 "model": "your-text-model-id",
3 "prompt": "Once upon a time",
4 "max_tokens": 256,
5 "temperature": 0.8,
6 "stream": false
7}Parameters
modelstringrequired
Text-completion model id (type: text).
promptstring | arrayrequired
Prompt or array of prompts to complete.
max_tokensinteger
Maximum tokens to generate.
temperaturenumber
Sampling temperature.
top_pnumber
Nucleus sampling probability mass.
frequency_penaltynumber
Penalize repeated tokens (-2 to 2).
presence_penaltynumber
Penalize tokens already present (-2 to 2).
stopstring | array
Up to 4 stop sequences.
streamboolean
If true, response is sent as SSE chunks.
ninteger
Number of completions to generate.
seedinteger
Deterministic sampling seed.
logprobsinteger
Top-N token log probabilities to return.
Response
📋200 OK
1{
2 "id": "cmpl-abc123",
3 "object": "text_completion",
4 "created": 1700000000,
5 "model": "your-text-model-id",
6 "choices": [
7 {
8 "index": 0,
9 "text": ", in a kingdom far away...",
10 "finish_reason": "length"
11 }
12 ],
13 "usage": { "prompt_tokens": 4, "completion_tokens": 8, "total_tokens": 12 }
14}ℹ
Streaming
Set
stream: true to receive Server-Sent Events. Each chunk has choices[].text with the next piece of the completion, and a final data: [DONE] sentinel.