Skip to main content

Create Completion (Legacy)

POST /v1/completions
This endpoint is deprecated. It is recommended to use /v1/chat/completions instead. Newer models may no longer support this endpoint.
The legacy Completions API accepts a text prompt and returns the model’s text completion result. Unlike Chat Completions, it does not use the message list format.

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel name
promptstring|arrayYesInput prompt text
max_tokensintegerNoMaximum tokens to generate, default 16
temperaturenumberNoSampling temperature, 0-2
top_pnumberNoNucleus sampling parameter
nintegerNoNumber of completions to generate
streambooleanNoWhether to stream output
stopstring|arrayNoStop tokens
echobooleanNoWhether to echo the input
suffixstringNoCompletion suffix

Example

curl https://crazyrouter.com/v1/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-3.5-turbo-instruct",
    "prompt": "Write a poem about spring:\n",
    "max_tokens": 200,
    "temperature": 0.7
  }'

Response Format

{
  "id": "cmpl-abc123",
  "object": "text_completion",
  "created": 1709123456,
  "model": "gpt-3.5-turbo-instruct",
  "choices": [
    {
      "text": "\nSpring breeze warms the land anew,\nBlossoms paint the morning dew.\nBirds return to build their nest,\nNature wakes from winter's rest.",
      "index": 0,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 36,
    "total_tokens": 48
  }
}
If you are developing a new application, please use the Chat Completions API directly. It is more powerful and supports more models.