Skip to content

Qwen3 Coder Next

alibaba/qwen3-coder-next — a llm model by Alibaba. Call it through the gateway’s standard OpenAI-compatible door using the catalog slug; the full parameter schema is reproduced in full below.

Catalog slugalibaba/qwen3-coder-next
Kindllm
VendorAlibaba
Context window1,000,000 tokens
Native model idqwen3-coder-next

Through the Sociaro SDK / OpenAI-compatible door

Section titled “Through the Sociaro SDK / OpenAI-compatible door”
from sociaro_ai import Sociaro
client = Sociaro(api_key="gw_live_...") # base_url defaults to https://api.sociaro.com
resp = client.chat.completions.create(
model="alibaba/qwen3-coder-next", # always the catalog slug
messages=[{"role": "user", "content": "Hello"}],
# any parameter from the schema below is passed through unchanged
)
print(resp.choices[0].message.content)

TypeScript: client.chat.completions.create({ model: "alibaba/qwen3-coder-next", messages: [...] }) — see the TypeScript SDK.

Through Alibaba DashScope’s native API (advanced)

Section titled “Through Alibaba DashScope’s native API (advanced)”

Optional: send Alibaba DashScope’s native request to the /alibaba prefix, using the native model id qwen3-coder-next. The gateway injects the upstream Alibaba DashScope credential and forwards the body unchanged (catalog, pricing and entitlements still apply).

Terminal window
curl https://api.sociaro.com/alibaba/<native-path> \
-H "Authorization: Bearer $SOCIARO_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "qwen3-coder-next", ... }'

The exact path, request body and response shape are documented in full in the schema below.

The complete, one-to-one API schema for this model, transcribed from the official source. Nothing omitted. Examples in the schema may use a representative model of the family — for this model use the slug alibaba/qwen3-coder-next (or the native id qwen3-coder-next for the native API) as shown in How to call above.

A SINGLE OpenAI-compatible contract (POST .../compatible-mode/v1/chat/completions) covers all Qwen text-chat families. There is no per-model parameter reference; only defaults and per-feature support lists differ. The same endpoint also serves Qwen-VL, Qwen-Omni, Qwen-Math, Qwen-Coder, and third-party models (DeepSeek, Kimi, GLM, MiniMax) routed through Model Studio.

Family / model groupSame /chat/completions contractNotable family-specific behavior
qwen3.7-max / qwen3.7-plusyesthinking ON by default; max_completion_tokens, tool_stream, preserve_thinking supported
qwen3.6-max / qwen3.6-plus / qwen3.6-flashyesthinking ON by default; tool_stream (plus/flash); preserve_thinking (plus)
qwen3.5-plus / qwen3.5-flashyesthinking ON by default; max_completion_tokens; tool_stream; search_strategy=agent
qwen3-max / qwen-maxyesqwen3-max: thinking OFF by default; search_strategy=agent, agent_max (thinking only)
qwen-plus / qwen-flashyeshybrid thinking OFF by default; presence_penalty default 0.5 in thinking mode
qwen3-coder-flash / -next / -plusyestext-chat contract; thinking-family rules apply per snapshot
qwen3 open-source (8b/14b/32b/30b-a3b/235b-a22b, -instruct/-thinking)yesn (1-4) only in non-thinking mode; logprobs supported; /think /no_think suffixes
Qwen-VL / Qwen3-VLyesadds multimodal content parts + vl_high_resolution_images, min/max/total_pixels, fps
Qwen-Omni (qwen3.5-omni-*, Qwen3-Omni-Flash)yesadds modalities, audio; audio output tokens
DeepSeek (v3.x/v4/r1)yesuses reasoning_effort (V4); enable_thinking for V4/V3.x; does NOT support top_k
Kimi (k2.x)yesthinking_budget supported; preserve_thinking (k2.6/k2.7-code); no top_k
GLM (4.6/4.7/5/5.1)yestool_stream; top_k default 20 (Alibaba direct); thinking ON by default
MiniMax (M2.x/M3)yesuses thinking object instead of enable_thinking; no top_k

Note: qwen-mt-* (machine translation) is a different family. It also posts to /chat/completions but adds a translation_options object (source_lang/target_lang/terms/tm_list/domains) that is NOT part of this chat contract.


Critical per-model differences (quick reference)

Section titled “Critical per-model differences (quick reference)”
  • enable_thinking default is per-model — NOT a fixed global default:
    • thinking ON by default: qwen3.7-max/plus, qwen3.6-max/plus/flash, qwen3.5-plus/flash, all open-source qwen3.5/qwen3.6/qwen3 hybrid models, GLM series (glm-4.5+).
    • thinking OFF by default: qwen3-max, qwen-max, qwen-plus, qwen-flash, DeepSeek-V4/V3.x (commercial hybrid), Kimi k2.6/k2.5.
    • thinking-only (cannot disable, no enable_thinking needed): qwen3.7-max-preview, qwen3-*-thinking, kimi-k2.7-code, deepseek-r1 family, MiniMax-M2.5/M2.1.
  • max_completion_tokens support: Qwen3.7-Max+, Qwen3.5-Plus+, Qwen3.5-Flash+, Kimi k2.5+, GLM glm-5+, MiniMax-M2.5+, DeepSeek (v3/r1/v3.1/v3.2/v4 list). Third-party direct-sale models excluded.
  • n (1-4): ONLY Qwen3 non-thinking mode; set n=1 when tools is passed.
  • presence_penalty default: 1.5 / 0.5 / 0.0 / 1 by model (full table below).
  • top_k default: 20 (most); Qwen3-Omni-Flash 50; GLM (Alibaba direct) 20. DeepSeek/Kimi/MiniMax do NOT support top_k.
  • reasoning_effort: ONLY DeepSeek-V4 (deepseek-v4-pro/-flash). Not for Qwen.
  • thinking object: ONLY MiniMax/MiniMax-M3 (Xiyu direct). Qwen uses enable_thinking.
  • tool_stream: qwen3.7-max/plus, qwen3.6-plus/flash, qwen3.5-plus/flash + GLM (4.6/4.7/5/5.1).
  • preserve_thinking: qwen3.7-max(+snapshots/-preview/-2026-05-17), qwen3.6-max-preview, qwen3.7-plus(-2026-05-26), qwen3.6-plus(-2026-04-02), kimi-k2.6, kimi-k2.7-code (and Moonshot-direct equivalents). NOT qwen3.5 / qwen-coder.
  • search_strategy=agent/agent_max: limited list (qwen3.5-plus/flash, qwen3-max, qwen3.5-omni-plus/flash); agent_max only thinking-mode qwen3-max.
  • logprobs: qwen-plus snapshots (not stable), qwen3-vl-plus/flash (incl. stable), Qwen3 open-source.

OpenAI-compatible mode. Method: POST {base_url}/chat/completions. Auth: Authorization: Bearer $DASHSCOPE_API_KEY, Content-Type: application/json. API keys are region-specific (a key from one region does not work in another).

RegionOpenAI-compatible base_urlNotes
Singapore (International) — currenthttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1New per-workspace MaaS domain; substitute real WorkspaceId.
Singapore (International) — legacyhttps://dashscope-intl.aliyuncs.com/compatible-mode/v1Docs recommend migrating to the MaaS form.
China (Beijing) — currenthttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1New per-workspace MaaS domain.
China (Beijing) — legacyhttps://dashscope.aliyuncs.com/compatible-mode/v1Docs recommend migrating to the MaaS form.
China (Hong Kong) — currenthttps://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/compatible-mode/v1Workspaces isolate API keys; create a workspace first.
China (Hong Kong) — legacyhttps://cn-hongkong.dashscope.aliyuncs.com/compatible-mode/v1Docs recommend migrating to the MaaS form.
US (Virginia)https://dashscope-us.aliyuncs.com/compatible-mode/v1Fixed domain (no WorkspaceId).
Germany (Frankfurt / EU)https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1Workspaces isolate API keys; create a workspace first.

{
"model": "qwen-plus",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"}
]
}

DashScope extensions (enable_thinking, thinking, thinking_budget, preserve_thinking, reasoning_effort, enable_search, search_options, top_k, repetition_penalty, vl_high_resolution_images, tool_stream, enable_code_interpreter) are not standard OpenAI parameters. Via the Python OpenAI SDK they go inside extra_body={...}. Via direct HTTP/curl they go at the JSON body root.

Correctness guard: frequency_penalty is NOT supported in DashScope’s OpenAI-compatible mode. The source exposes only presence_penalty (verified: the compatibility page contains frequency_penalty 0 times). Do not add frequency_penalty. Constraint: streaming output cannot be combined with the tools parameter (per compatibility page); and when using tools, set n=1.


ParameterTypeRequiredDefaultAllowed values / rangeDescription
modelstringYesa model name (Qwen LLM commercial/open-source, Qwen-VL, Qwen-Coder, Qwen-Omni, Qwen-Math; DeepSeek, Kimi, GLM, MiniMax)The model to call. Exact names + billing: check console.
messagesarrayYeschronological message arrayConversation history. Message types: System / User / Assistant / Tool (nested spec below).
streambooleanNofalsetrue | falseStreaming (SSE). false returns full content after generation; true returns chunks incrementally. For non-stream calls, if the request does not finish within 300 s the service interrupts and returns content generated so far (not an error) — prefer true for long outputs.
stream_optionsobjectNoeffective only when stream=trueStreaming options. Property include_usage (boolean, default false): include token-usage info in the last chunk.
modalitiesarrayNo["text"]["text"] | ["text","audio"]Qwen-Omni only. Output modalities.
audioobjectNorequires modalities=["text","audio"]Qwen-Omni only. Output audio config. Properties: voice (string, Required); format (string, Required) — only wav.
temperaturefloatNomodel-dependent0 ≤ x < 2Sampling temperature. Set EITHER temperature OR top_p, not both.
top_pfloatNomodel-dependent(0, 1.0]Nucleus sampling. Set EITHER temperature OR top_p.
top_kintegerNo20 (most); Qwen3-Omni-Flash 50; GLM (Alibaba direct) 20integer ≥ 0; null or >100 disables top_k (only top_p applies)Candidate-token count for sampling. Non-standard OpenAI → extra_body. DeepSeek/Kimi/MiniMax do NOT support it.
repetition_penaltyfloatNomodel-dependent> 0, no strict upper limit; 1.0 = no penaltyPenalty on repeated consecutive sequences. Non-standard → extra_body.
presence_penaltyfloatNomodel-dependent (table below)-2.0 … 2.0Penalty on tokens already present. Positive reduces repetition; negative increases. Supported by commercial Qwen + open-source models.
response_formatobjectNo{"type":"text"}{"type":"text"} | {"type":"json_object"}Response format. For json_object you MUST also instruct JSON in the prompt or an error occurs. Property type (string, Required): text | json_object.
max_tokensintegerNo (Deprecated)model max output lengthintegerDeprecated — use max_completion_tokens. Caps response tokens; on hit finish_reason="length". Does NOT limit chain-of-thought length.
max_completion_tokensintegerNomodel max output lengthintegerCaps total response tokens including chain-of-thought; on hit finish_reason="length". Recommended for reasoning models. Supported: Qwen3.7-Max+, Qwen3.5-Plus+, Qwen3.5-Flash+, Kimi k2.5+, GLM glm-5+, MiniMax-M2.5+, DeepSeek (v3/r1/r1-0528/v3.1/v3.2/v3.2-exp/v4-pro/v4-flash and later). Third-party direct-sale models excluded. Actual output may differ by up to 10 tokens.
vl_high_resolution_imagesbooleanNofalsetrue | falseQwen-VL only. Raises image pixel cap to the 16384-token equivalent (fixed-resolution strategy, ignores max_pixels). true cap: Qwen3.7/3.6/3.5/Qwen3-VL → 16777216 px (32×32/token). Non-standard → extra_body.
nintegerNo11 … 4Number of candidate responses. Only Qwen3 non-thinking mode. Set to 1 when tools is passed. Increases only output tokens (not input).
enable_thinkingbooleanNomodel-dependent (see per-model differences)true | falseToggles hybrid thinking. Models: Qwen3.7/3.6/3.5/Qwen3/Qwen3-Omni-Flash/Qwen3-VL, DeepSeek-V4-Pro/V4-Flash, DeepSeek-V3.2/V3.2-exp/V3.1, Kimi-K2.7-code (thinking-only)/K2.6/K2.5, GLM. When true, reasoning returns in reasoning_content. Non-standard → extra_body. MiniMax/MiniMax-M3 (Xiyu direct) uses thinking instead.
thinkingobjectNo{"type":"adaptive"}type: adaptive | disabledMiniMax/MiniMax-M3 (Xiyu direct) only. adaptive = model decides; disabled = no thinking. Non-standard → extra_body.
preserve_thinkingbooleanNofalsetrue | falseRe-feed prior assistant reasoning_content into input. Models: qwen3.7-max (+ -2026-05-20/-06-08 snapshots, -preview, -2026-05-17), qwen3.6-max-preview, qwen3.7-plus(-2026-05-26), qwen3.6-plus(-2026-04-02), kimi-k2.6, kimi-k2.7-code (default-on), kimi/kimi-k2.7-code (Moonshot direct, default-on). Re-fed reasoning is billed as input. Enabling with no prior reasoning_content is not an error. Non-standard → extra_body.
thinking_budgetintegerNomodel max chain-of-thought lengthintegerMax tokens for the thinking process; on reaching it the model stops reasoning and answers. Supported by Qwen3 (in thinking mode) — Qwen3.7, Qwen3.6, Qwen3.5, Qwen3-VL and the Qwen3 commercial and open-source models — and by Kimi models. Non-standard → extra_body.
reasoning_effortstringNohighhigh | max (low/medium→high, xhigh→max)DeepSeek-V4 only (deepseek-v4-pro/-flash). Reasoning intensity. Non-standard → extra_body.
tool_streambooleanNofalsetrue | false; effective only when stream=trueStream complex tool arguments (array/object types). Qwen: qwen3.7-max (text), qwen3.7-plus/qwen3.6-plus (text), qwen3.5-plus (all modalities), qwen3.6-flash/qwen3.5-flash (all modalities). GLM: glm-4.6/4.7/5/5.1. Simple args stream whenever stream=true. Non-standard → extra_body.
enable_code_interpreterbooleanNofalsetrue | falseEnables the code interpreter feature. Non-standard → extra_body.
seedintegerNo[0, 2^31−1]RNG seed for reproducibility (same seed + unchanged params → same result when possible).
logprobsbooleanNofalsetrue | falseReturn log-probabilities of output tokens (reasoning_content excluded). Models: qwen-plus snapshots (not stable), qwen3-vl-plus (incl. stable), qwen3-vl-flash (incl. stable), Qwen3 open-source.
top_logprobsintegerNo00 … 5Number of top candidate tokens per step. Effective only when logprobs=true.
stopstring or arrayNostring / array of strings or token_idsStop words: generation stops immediately on appearance. Do NOT mix strings and token_ids in one array (e.g. ["Hello",104307] is invalid).
toolsarrayNoarray of tool objectsFunction-calling tool definitions. When a tool fires, the response carries tool_calls. Properties: type (string, Required, only function); function (object, Required) → name (string, Required; letters/digits/_/-; ≤64 tokens), description (string, Required), parameters (object, Optional, default {}, valid JSON Schema).
tool_choicestring or objectNoautoauto | none | {"type":"function","function":{"name":"..."}}Tool-selection policy. none disables; object forces a specific tool. Thinking-mode models cannot force a specific tool.
parallel_tool_callsbooleanNofalsetrue | falseEnable parallel tool calling.
enable_searchbooleanNofalsetrue | falseEnable web search. May increase token usage. If search does not trigger, optimize the prompt or set search_options.forced_search. Non-standard → extra_body.
search_optionsobjectNoeffective only when enable_search=trueWeb-search strategy (sub-properties below). Non-standard → extra_body.
PropertyTypeRequiredDefaultAllowed valuesDescription
forced_searchbooleanOptionalfalsetrue | falseForce web search (true) vs. let the model decide (false). Effective only when enable_search=true.
search_strategystringOptionalturboturbo | max | agent | agent_maxturbo = balanced; max = broader multi-engine search (slower); agent = multi-round retrieve+integrate (only qwen3.5-plus/-2026-02-15, qwen3.5-flash/-2026-02-23, qwen3-max/-2026-01-23/-2025-09-23, qwen3.5-omni-plus/-2026-03-15, qwen3.5-omni-flash/-2026-03-15); agent_max = agent + web extraction (only thinking-mode qwen3-max & qwen3-max-2026-01-23).
enable_search_extensionbooleanOptionalfalsetrue | falseDomain-specific search. Effective only when enable_search=true.

DashScope-native protocol additionally exposes enable_source (return search sources in output.search_info.search_results); this is a DashScope-API field, not part of the OpenAI-compatible body.

  • 1.5: Qwen3.7 (non-thinking), Qwen3.6 (non-thinking), Qwen3.5-Omni, Qwen3.5 (non-thinking), qwen3-max-preview (thinking), Qwen3 (non-thinking), Qwen3-Instruct/1.7b/4b (thinking), qwen-max, Qwen3-VL (non-thinking).
  • 0.5: qwen3-8b/14b/32b/30b-a3b/235b-a22b (thinking), qwen-plus/qwen-plus-latest/2025-04-28 (thinking).
  • 0.0: all other models; Kimi (k2.7-code/k2.6/k2.5, Alibaba & Moonshot direct); MiniMax (M2.5/M2.1).
  • 1: DeepSeek deepseek-r1, deepseek-r1-0528, deepseek-r1-distill-qwen distill series.
  • Other DeepSeek/Kimi/GLM/MiniMax models: no default value.

System Message (object, Optional; place at start of array):

PropertyTypeRequiredDescription
contentstringYesSystem instruction: role/behavior/style/constraints.
rolestringYesFixed system.

User Message (object, Required):

PropertyTypeRequiredDescription
contentstring or arrayYesString for text-only; array for multimodal input or explicit caching.
rolestringYesFixed user.

content array elements (multimodal models / explicit caching) — each element has a type:

FieldTypeDescription
typestring (Required)text | image_url | input_audio | video (video as image list) | video_url (video file). Only some Qwen-VL accept video files; Qwen-Omni accept direct video files.
textstringText (when type=text). Required when type=text.
image_urlobject{url: string (Required)} — URL or Base64 Data URL (when type=image_url).
input_audioobject{data: string (Required) — URL/Base64; format: string (Required), e.g. mp3/wav} (when type=input_audio).
videoarrayList of image URLs treated as a video (when type=video).
video_urlobject{url: string (Required)} — URL/Base64 of a video file (when type=video_url).
fpsfloat (Optional)default 2.0; range [0.1, 10] (MiniMax/MiniMax-M3: [0.2, 5], default 1). Frame-extraction rate (1 frame per 1/fps s) and inter-frame interval hint.
min_pixelsinteger (Optional)Min pixel threshold per image/frame; upscales below it. Per-model defaults (image): Qwen3.7/3.6/3.5/Qwen3-VL 65536; Qwen3.5-Omni 24576. (Video/list defaults differ — see source.)
max_pixelsinteger (Optional)Max pixel threshold per image/frame; downscales above it. Interacts with vl_high_resolution_images (when true, max_pixels is ignored). Per-model defaults vary (image, vl_high=false): Qwen3.7/3.6/3.5/Qwen3-VL 2621440 (max 16777216); Qwen3.5-Omni 1310720.
total_pixelsinteger (Optional)Cap on summed pixels across all extracted video frames (keeps each frame within [min_pixels,max_pixels]). Per-model defaults: Qwen3.7/3.6/3.5 819200000 (=800000 img tokens @32×32); Qwen3.5-Omni 184549376; close-source Qwen3-VL & 235b-a22b 134217728; other Qwen3-VL open-source 67108864; others 51380224.
cache_controlobject (Optional)Explicit caching. {type: string (Required), only ephemeral}.

Assistant Message (object, Optional):

PropertyTypeRequiredDefaultDescription
contentstringOptionalReply text. May be empty if tool_calls present; otherwise required.
rolestringYesFixed assistant.
partialbooleanOptionalfalseEnable partial mode (prefix continuation).
tool_callsarrayOptionalFrom a prior response. Elements: id (string, Req), type (string, Req, only function), function (object, Req → name string Req, arguments string Req — JSON string), index (integer, Req).

Tool Message (object, Optional):

PropertyTypeRequiredDescription
contentstringYesTool function output (must be a string; serialize structured/JSON output).
rolestringYesFixed tool.
tool_call_idstringYesID from completion.choices[0].message.tool_calls[$index].id.

Response — non-streaming (object: "chat.completion")

Section titled “Response — non-streaming (object: "chat.completion")”
{
"choices": [
{
"message": {
"role": "assistant",
"content": "I am a large-scale language model developed by Alibaba Cloud. My name is Qwen."
},
"finish_reason": "stop",
"index": 0,
"logprobs": null
}
],
"object": "chat.completion",
"usage": {
"prompt_tokens": 3019,
"completion_tokens": 104,
"total_tokens": 3123,
"prompt_tokens_details": {"cached_tokens": 2048}
},
"created": 1735120033,
"system_fingerprint": null,
"model": "qwen-plus",
"id": "chatcmpl-6ada9ed2-7f33-9de2-8bb0-78bd4035025a"
}
FieldTypeDescription
idstringUnique request identifier.
choicesarrayGenerated content. Per element: finish_reason (stop|length|tool_calls), index (integer), logprobs (object), message (object).
choices[].logprobsobjectcontent[]token (string), bytes[] (array of UTF-8 bytes), logprob (float; null = extremely low), top_logprobs[]token/bytes/logprob.
choices[].messageobjectcontent (string), reasoning_content (string — chain-of-thought), refusal (always null), role (always assistant), audio (always null in non-stream), function_call (deprecated, always null), tool_calls[]id, type (function), function{name,arguments}, index.
createdintegerUnix timestamp (s) of request creation.
modelstringModel used.
objectstringAlways chat.completion.
service_tierstringCurrently always null.
system_fingerprintstringCurrently always null.
usageobjectcompletion_tokens, prompt_tokens, total_tokens, completion_tokens_details{audio_tokens(null in non-stream), reasoning_tokens(null in non-stream), text_tokens}, prompt_tokens_details{audio_tokens(null in non-stream), cached_tokens, text_tokens, image_tokens, video_tokens}, cache_creation{ephemeral_5m_input_tokens, cache_creation_input_tokens}, cache_type(ephemeral when explicit cache used; otherwise absent).

Response — streaming (object: "chat.completion.chunk")

Section titled “Response — streaming (object: "chat.completion.chunk")”

Each chunk:

  • id (shared across all chunks of one response)
  • choices[] with:
    • delta: content (string, incremental), reasoning_content (string, incremental CoT), function_call (null), audio{data (Base64, incremental), expires_at (UNIX ts)} (Qwen-Omni), refusal (null), role (first chunk only), tool_calls[]{index, id, function{arguments (concatenate across chunks), name (first chunk only)}, type (function)}
    • finish_reason: stop | length | tool_calls | null (before completion)
    • index (integer; use to reassemble per-candidate output when n>1)
    • logprobs (object, same shape as non-stream)
  • created, model, object (chat.completion.chunk), service_tier (null), system_fingerprint (null)
  • usage: present only in the final chunk when stream_options.include_usage=true; in that final chunk choices is empty.

In streaming usage, completion_tokens_details carries real audio_tokens/reasoning_tokens/text_tokens, and prompt_tokens_details carries audio_tokens (incl. audio-in-video tokens), text_tokens, video_tokens, image_tokens, cached_tokens; plus cache_creation{ephemeral_5m_input_tokens, cache_creation_input_tokens} and cache_type (ephemeral).

Final-chunk usage example:

{"id":"chatcmpl-...","choices":[],"created":1735113344,"model":"qwen-plus","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":{"completion_tokens":17,"prompt_tokens":22,"total_tokens":39,"completion_tokens_details":null,"prompt_tokens_details":{"audio_tokens":null,"cached_tokens":0}}}

The OpenAI-compatible /chat/completions endpoint for Qwen text-chat is synchronous (streaming or non-streaming). There is no async create/poll job model for chat completions in this contract. (Asynchronous job-based invocation in DashScope applies to other modalities — e.g. video generation, file-based ASR — via the DashScope-native /api/v1 task endpoints, not this OpenAI-compatible chat contract.)


  • usage is returned in the final chunk when stream_options.include_usage=true (the gateway’s exact-billing path injects this).
  • prompt_tokens_details.cached_tokens reflects context-cache hits.
  • reasoning_content (CoT) is billed as output; when preserve_thinking=true, re-fed prior reasoning is billed as input.
  • Audio output (Qwen-Omni) and audio-in-video tokens surface under the respective *_tokens_details fields.

Terminal window
curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-plus",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"}
]
}'

Python (OpenAI SDK):

import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen-plus",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"},
],
)
print(completion.model_dump_json())

Full example (curl, with DashScope extensions)

Section titled “Full example (curl, with DashScope extensions)”
Terminal window
curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.5-plus",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the weather like in Hangzhou?"}
],
"stream": true,
"stream_options": {"include_usage": true},
"temperature": 0.7,
"top_p": 0.8,
"top_k": 20,
"presence_penalty": 1.5,
"repetition_penalty": 1.0,
"max_completion_tokens": 2048,
"seed": 1234,
"stop": ["<end>"],
"logprobs": true,
"top_logprobs": 3,
"response_format": {"type": "text"},
"enable_thinking": true,
"thinking_budget": 8192,
"enable_search": true,
"search_options": {"forced_search": true, "search_strategy": "turbo", "enable_search_extension": false},
"tool_stream": true,
"parallel_tool_calls": true,
"tool_choice": "auto",
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get weather for a city.",
"parameters": {
"type": "object",
"properties": {"location": {"type": "string", "description": "City name"}},
"required": ["location"]
}
}
}
]
}'

Via the Python OpenAI SDK, move non-standard fields into extra_body={...}: enable_thinking, thinking, thinking_budget, preserve_thinking, reasoning_effort, enable_search, search_options, enable_code_interpreter, tool_stream, top_k, repetition_penalty, vl_high_resolution_images.

Python (extra_body for thinking + search + budget):

completion = client.chat.completions.create(
model="qwen3.5-plus",
messages=[{"role": "user", "content": "Latest Alibaba stock price?"}],
stream=True,
stream_options={"include_usage": True},
extra_body={
"enable_thinking": True,
"thinking_budget": 8192,
"enable_search": True,
"search_options": {"forced_search": True, "search_strategy": "agent"},
},
)