Theme
Qwen Completions
Generate text with an OpenAI Legacy Completions–compatible format (Qwen).
http
POST /v1/completionsLegacy 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
| Model | Description |
|---|---|
| Qwen 3.7 enhanced model |
Headers
| Name | Type | Required | Description |
|---|---|---|---|
| string | Yes | Request authentication. Use a Bearer Token, for example: | |
| string | Yes | Request content type; must be |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| string | Yes | Model ID; default example ; see Available models above | |
| string | array | Yes | Input 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 | |
| string | No | Suffix that appears after the inserted completion; only supports this | |
| integer | No | Maximum tokens to generate; official default ; prompt tokens plus this value must not exceed the model context length | |
| number | No | Sampling temperature, range –, default ; usually tune either or | |
| number | No | Nucleus sampling, range –, default | |
| integer | No | How many completions to generate per prompt, range –, default | |
| boolean | No | Whether to stream; default ; when enabled, SSE pushes chunks and ends with | |
| object | No | Streaming options; only effective when | |
| integer | No | Number of most likely token log probabilities to return; maximum | |
| boolean | No | Whether to echo the prompt in addition to the completion; default | |
| string | array | No | Up to 4 stop sequences; generation stops when encountered | |
| number | No | Range –, default | |
| number | No | Range –, default | |
| integer | No | Server generates multiple candidates and returns the best; default , maximum ; cannot be used with streaming; when used with , must be greater than | |
| object | No | Bias for specific token probabilities; keys are token IDs, values – | |
| integer | No | Random seed; best-effort deterministic sampling | |
| string | No | Unique end-user identifier for abuse monitoring |
stream_options
| Name | Type | Required | Description |
|---|---|---|---|
| boolean | No | Emit 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
| Name | Type | Description |
|---|---|---|
| string | Completion response ID | |
| string | Object type; always | |
| integer | Response creation timestamp (seconds) | |
| string | Model that generated the response | |
| array | Candidate results | |
| integer | Candidate index | |
| string | Text generated by the model | |
| string | Finish reason, e.g. | |
| object | Token usage stats | |
| integer | Input token count | |
| integer | Output token count | |
| integer | Total token count |