Skip to content

Qwen Completions

Generate text with an OpenAI Legacy Completions–compatible format (Qwen).

http
POST /v1/completions

Legacy Completions takes as input. It fits workloads that still use older OpenAI-compatible SDKs or need simple text completion. For new chat scenarios, prefer Qwen Chat Completions.

The default example model is .

Available models

ModelDescription
Qwen 3.7 enhanced model

Headers

NameTypeRequiredDescription
stringYesRequest authentication. Use a Bearer Token, for example:
stringYesRequest content type; must be

Request body

NameTypeRequiredDescription
stringYesModel ID; default example ; see Available models above
string | arrayYesInput prompt. May be a string, array of strings, array of tokens, or array of token arrays; the official default generates from the document start marker
stringNoSuffix that appears after the inserted completion; only supports this
integerNoMaximum tokens to generate; official default ; prompt tokens plus this value must not exceed the model context length
numberNoSampling temperature, range , default ; usually tune either or
numberNoNucleus sampling, range , default
integerNoHow many completions to generate per prompt, range , default
booleanNoWhether to stream; default ; when enabled, SSE pushes chunks and ends with
objectNoStreaming options; only effective when
integerNoNumber of most likely token log probabilities to return; maximum
booleanNoWhether to echo the prompt in addition to the completion; default
string | arrayNoUp to 4 stop sequences; generation stops when encountered
numberNoRange , default
numberNoRange , default
integerNoServer generates multiple candidates and returns the best; default , maximum ; cannot be used with streaming; when used with , must be greater than
objectNoBias for specific token probabilities; keys are token IDs, values
integerNoRandom seed; best-effort deterministic sampling
stringNoUnique end-user identifier for abuse monitoring

stream_options

NameTypeRequiredDescription
booleanNoEmit an extra chunk with before

Request example

bash
curl -X POST https://octopusx.ai/v1/completions \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.7-plus",
    "prompt": "Rewrite the following sentence to be more formal: This API is pretty easy to use.",
    "max_tokens": 120,
    "temperature": 0.3
  }'
bash
curl -X POST https://octopusx.ai/v1/completions \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.7-plus",
    "prompt": "Summarize the Completions API in one sentence.",
    "max_tokens": 64,
    "stream": true,
    "stream_options": {
      "include_usage": true
    }
  }'

Response example

Non-streaming success

json
{
  "id": "cmpl_abc123",
  "object": "text_completion",
  "created": 1735689600,
  "model": "qwen3.7-plus",
  "choices": [
    {
      "index": 0,
      "text": "This API offers good usability.",
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 22,
    "completion_tokens": 10,
    "total_tokens": 32
  }
}

Streaming chunk (illustrative)

text
data: {"id":"cmpl_abc123","object":"text_completion","choices":[{"index":0,"text":"This","finish_reason":null}]}

data: {"id":"cmpl_abc123","object":"text_completion","choices":[{"index":0,"text":" API","finish_reason":null}]}

data: [DONE]

Response fields

NameTypeDescription
stringCompletion response ID
stringObject type; always
integerResponse creation timestamp (seconds)
stringModel that generated the response
arrayCandidate results
integerCandidate index
stringText generated by the model
stringFinish reason, e.g.
objectToken usage stats
integerInput token count
integerOutput token count
integerTotal token count