POST
/
v1
/
completions
curl -X POST "https://api.applerouter.ai/v1/completions" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-3.5-turbo-instruct",
    "prompt": "Write a haiku about programming:",
    "max_tokens": 50,
    "temperature": 0.7
  }'
{
  "id": "cmpl-abc123",
  "object": "text_completion",
  "created": 1700000000,
  "model": "gpt-3.5-turbo-instruct",
  "choices": [
    {
      "text": "\nLines of code cascade,\nBugs emerge from logic's maze,\nDebug, repeat, win.",
      "index": 0,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 6,
    "completion_tokens": 20,
    "total_tokens": 26
  }
}

Overview

Generates a text completion for a given prompt. This is the legacy Completions API - for most use cases, prefer the Chat Completions API.
model
string
required
The model ID to use
prompt
string | array
required
The prompt to generate completions for
max_tokens
integer
Maximum number of tokens to generate
temperature
number
Sampling Temperature (0-2)
top_p
number
Nucleus sampling parameter (Top P)
n
integer
Number of completions to generate
stream
boolean
Enable Streaming responses
stop
string | array
Stop sequences
suffix
string
Suffix to append after completion
echo
boolean
Echo back the prompt in the response
curl -X POST "https://api.applerouter.ai/v1/completions" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-3.5-turbo-instruct",
    "prompt": "Write a haiku about programming:",
    "max_tokens": 50,
    "temperature": 0.7
  }'
{
  "id": "cmpl-abc123",
  "object": "text_completion",
  "created": 1700000000,
  "model": "gpt-3.5-turbo-instruct",
  "choices": [
    {
      "text": "\nLines of code cascade,\nBugs emerge from logic's maze,\nDebug, repeat, win.",
      "index": 0,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 6,
    "completion_tokens": 20,
    "total_tokens": 26
  }
}
For conversational and instruction-following tasks, please use the Chat Completions API (/v1/chat/completions) instead.

Authorizations

Authorization
string
header
required

使用 Bearer Token 认证。格式: Authorization: Bearer sk-xxxxxx

Body

application/json
model
string
required
prompt
required
max_tokens
integer
temperature
number
top_p
number
n
integer
stream
boolean
stop
suffix
string
echo
boolean

Response

200 - application/json

成功创建响应

id
string
object
string
Example:

"text_completion"

created
integer
model
string
choices
object[]
usage
object