Skip to content

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/completions

Use 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

ModelDescription
Qwen 3.7 high-spec model
Qwen 3.7 enhanced model
Qwen 3.6 enhanced model
Qwen 3.5 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
arrayYesConversation messages in chronological order
booleanNoWhether to stream the response; defaults to non-streaming
objectNoStreaming options; only effective when
integerNoUpper bound on generated tokens (visible output plus reasoning tokens); recommended for reasoning models
integerNoMaximum number of tokens to generate; deprecated, prefer
numberNoSampling temperature, range , default
numberNoNucleus sampling, range , default ; usually tune either or
integerNoNumber of candidate results, range , default
string | arrayNoUp to 4 stop sequences
numberNoRange , default
numberNoRange , default
objectNoBias for specific token appearance probabilities
booleanNoWhether to return log probabilities for output tokens; default
integerNo; requires set to
integerNoRandom seed (Beta); best-effort deterministic sampling
objectNoOutput format; commonly used for JSON / structured output
arrayNoTools the model may call
string | objectNoControls tool use: / / , or a specific function
booleanNoWhether to allow parallel tool calls; default
stringNoReasoning effort: / / / / / /
stringNoReply verbosity: / / ; supported by Qwen models
arrayNoOutput modalities; default ; audio models may include
objectNoAudio output parameters; required when includes
objectNoPredicted outputs config; can reduce latency for predictable content
booleanNoWhether to store this output; default
objectNoUp to 16 key-value pairs of extra metadata
stringNoProcessing tier: / / / / /
objectNoWeb search options (search-capable models)
stringNoPrompt cache key
stringNoStable end-user identifier, up to 64 characters
stringNoEnd-user identifier; deprecated, use /

messages item

NameTypeRequiredDescription
stringYes, , , ,
string | array | nullYesPlain text string, or a multimodal part array ( / / / , etc.); for tool calls, content may be
stringNoOptional participant name
arrayNo only: tool calls initiated by the model
stringConditionalRequired for messages: matching tool call ID

stream_options

NameTypeRequiredDescription
booleanNoEmit an extra chunk with before
booleanNoStream obfuscation to normalize payload size

response_format

NameTypeRequiredDescription
stringNo (default), , or
objectConditionalProvide when is ; includes , , etc.

tools item

NameTypeRequiredDescription
stringYesFunction tools must be
objectYesIncludes , , (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

NameTypeDescription
stringResponse ID for this generation
stringNon-streaming: ; streaming:
integerCreation timestamp (seconds)
stringModel ID actually used
arrayCandidate results
objectNon-streaming: message generated by the model
string | nullText content; may be for tool calls
arrayFunction tools the model requested
objectStreaming: incremental content ( / / / )
stringFinish reason: , , , etc.
objectToken usage; for streaming, upstream must return it and often requires
integerInput token count
integerOutput token count
integerTotal 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.