Theme
Qwen Chat Completions
Call Qwen with an OpenAI Chat Completions–compatible format. Supports a full one-shot response and SSE streaming.
http
POST /v1/chat/completionsUse a unified chat message format to call Qwen upstream models. stream controls the return mode: omit it or pass false to receive a complete chat.completion object in one response—good for background jobs, structured output, and short Q&A; pass true for SSE incremental chunks—good for chat UIs, agents, and long-form generation.
When stream is omitted, the request is treated as non-streaming. To require streaming, pass "stream": true explicitly.
The default model is .
Available models
| Model | Description |
|---|---|
| Qwen 3.7 high-spec model | |
| Qwen 3.7 enhanced model | |
| Qwen 3.6 enhanced model | |
| Qwen 3.5 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 | |
| array | Yes | Conversation messages in chronological order | |
| boolean | No | Whether to stream the response; defaults to non-streaming | |
| object | No | Streaming options; only effective when | |
| integer | No | Upper bound on generated tokens (visible output plus reasoning tokens); recommended for reasoning models | |
| integer | No | Maximum number of tokens to generate; deprecated, prefer | |
| number | No | Sampling temperature, range –, default | |
| number | No | Nucleus sampling, range –, default ; usually tune either or | |
| integer | No | Number of candidate results, range –, default | |
| string | array | No | Up to 4 stop sequences | |
| number | No | Range –, default | |
| number | No | Range –, default | |
| object | No | Bias for specific token appearance probabilities | |
| boolean | No | Whether to return log probabilities for output tokens; default | |
| integer | No | –; requires set to | |
| integer | No | Random seed (Beta); best-effort deterministic sampling | |
| object | No | Output format; commonly used for JSON / structured output | |
| array | No | Tools the model may call | |
| string | object | No | Controls tool use: / / , or a specific function | |
| boolean | No | Whether to allow parallel tool calls; default | |
| string | No | Reasoning effort: / / / / / / | |
| string | No | Reply verbosity: / / ; supported by Qwen models | |
| array | No | Output modalities; default ; audio models may include | |
| object | No | Audio output parameters; required when includes | |
| object | No | Predicted outputs config; can reduce latency for predictable content | |
| boolean | No | Whether to store this output; default | |
| object | No | Up to 16 key-value pairs of extra metadata | |
| string | No | Processing tier: / / / / / | |
| object | No | Web search options (search-capable models) | |
| string | No | Prompt cache key | |
| string | No | Stable end-user identifier, up to 64 characters | |
| string | No | End-user identifier; deprecated, use / |
messages item
| Name | Type | Required | Description |
|---|---|---|---|
| string | Yes | , , , , | |
| string | array | null | Yes | Plain text string, or a multimodal part array ( / / / , etc.); for tool calls, content may be | |
| string | No | Optional participant name | |
| array | No | only: tool calls initiated by the model | |
| string | Conditional | Required for messages: matching tool call ID |
stream_options
| Name | Type | Required | Description |
|---|---|---|---|
| boolean | No | Emit an extra chunk with before | |
| boolean | No | Stream obfuscation to normalize payload size |
response_format
| Name | Type | Required | Description |
|---|---|---|---|
| string | No | (default), , or | |
| object | Conditional | Provide when is ; includes , , etc. |
tools item
| Name | Type | Required | Description |
|---|---|---|---|
| string | Yes | Function tools must be | |
| object | Yes | Includes , , (JSON Schema); optional |
Request example
bash
curl -X POST https://octopusx.ai/v1/chat/completions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-max",
"messages": [
{ "role": "system", "content": "You are an API documentation assistant." },
{ "role": "user", "content": "Generate a short API description summary." }
],
"stream": false
}'bash
curl -X POST https://octopusx.ai/v1/chat/completions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-max",
"messages": [
{ "role": "user", "content": "Summarize Chat Completions in one sentence." }
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'bash
curl -X POST https://octopusx.ai/v1/chat/completions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-max",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Describe this image." },
{
"type": "image_url",
"image_url": { "url": "https://example.com/image.png" }
}
]
}
]
}'bash
curl -X POST https://octopusx.ai/v1/chat/completions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.7-max",
"messages": [
{ "role": "user", "content": "Extract the contact name and email." }
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "contact",
"strict": true,
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"email": { "type": "string" }
},
"required": ["name", "email"],
"additionalProperties": false
}
}
}
}'Response example
Non-streaming success
json
{
"id": "chatcmpl_abc123",
"object": "chat.completion",
"created": 1735689600,
"model": "qwen3.7-max",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "This endpoint accepts unified chat messages and returns a complete reply from the model in one response."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 31,
"completion_tokens": 24,
"total_tokens": 55
}
}Streaming chunk (illustrative)
text
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"This"},"finish_reason":null}]}
data: {"id":"chatcmpl_abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" endpoint"},"finish_reason":null}]}
data: [DONE]Response fields
| Name | Type | Description |
|---|---|---|
| string | Response ID for this generation | |
| string | Non-streaming: ; streaming: | |
| integer | Creation timestamp (seconds) | |
| string | Model ID actually used | |
| array | Candidate results | |
| object | Non-streaming: message generated by the model | |
| string | null | Text content; may be for tool calls | |
| array | Function tools the model requested | |
| object | Streaming: incremental content ( / / / ) | |
| string | Finish reason: , , , etc. | |
| object | Token usage; for streaming, upstream must return it and often requires | |
| integer | Input token count | |
| integer | Output token count | |
| integer | Total token count |
Notes
TIP
Parameters marked Optional on this page are not necessarily supported by every model. Whether a field is forwarded and takes effect depends on the capabilities of the model you are routed to.
WARNING
Streaming responses use text/event-stream. Clients must parse SSE data: lines and treat data: [DONE] as the end marker.