Skip to main content
POST

Authorizations

Authorization
string
header
required

Pass Authorization: Bearer header.

Body

application/json
model
enum<string>
required

Model name. Only publicly available chat models in the current Ali channel's final whitelist are supported.

Available options:
qwen3.7-max
Example:

"qwen3.7-max"

messages
(System Message object (optional) · object | User Message object (required) · object | Assistant Message object (optional) · object | Tool Message object (optional) · object)[]
required

Context passed to the model, arranged in conversation order. Supports four message types: System Message, User Message, Assistant Message, and Tool Message. Supports plain text, multimodal (image/video/audio) content, and explicit caching.

System message. Used to set the model's role, tone, task goals, or constraints. Typically placed first in the messages array.

stream
boolean
default:false

Whether to stream the response. Values:

  • false: Returns the entire content at once after generation completes;
  • true: Streams output as it is generated, returning each chunk as it becomes available. Chunks must be read in real time and concatenated to assemble the full response.

Recommended to set to true for better reading experience and lower timeout risk.

Note: Non-streaming calls that do not complete within 300 seconds will be interrupted and return the already generated content (not an error). Streaming is strongly recommended for longer outputs.

stream_options
object

Stream output configuration. Only effective when stream is true.

temperature
number
default:0.7

Sampling temperature, controlling the diversity of generated text. Higher temperature produces more diverse output; lower temperature produces more deterministic output. Range: [0, 2). temperature and top_p both control text diversity; it is recommended to set only one of them.

Required range: 0 <= x <= 2
top_p
number
default:0.95

Nucleus sampling probability threshold, controlling text diversity. Higher top_p produces more diverse output; lower top_p produces more deterministic output. Range: (0, 1.0]. temperature and top_p both control text diversity; it is recommended to set only one of them.

Required range: 0 <= x <= 1
stop

Used to specify stop sequences. When the text generated by the model contains a string specified by stop, generation will terminate immediately.

Sensitive words can be passed to control model output.

When stop is an array, token_id and strings cannot be mixed as elements. For example, specifying ["hello", 104307] is not allowed.

seed
integer

Random seed. Used to ensure reproducible results with the same input and parameters. If called with the same seed and other parameters unchanged, the model will return the same results as much as possible.

Range: [0, 2^31−1].

Seed defaults:

  • qwen-vl-max, qvq-max series: 3407;
  • qwen-vl-max-2024-02-01, qwen-vl-plus: no default;
  • All other models: 1234.
Required range: 0 <= x <= 2147483647
tools
object[]

An array of one or more tool objects for the model to call in Function Calling.

When tools is set and the model determines a tool call is needed, the response returns tool information through tool_calls.

Properties:

  • type (required): Tool type, currently only supports function.
  • function (required): Tool and parameter information.
    • name (required): Tool name. Only allows letters, numbers, underscores (_) and dashes (-), up to 64 tokens.
    • description (required): Tool description to help the model determine when and how to call the tool.
    • parameters (optional, default {}): Tool parameter description, must be a valid JSON Schema. If parameters is empty, the tool has no input parameters (e.g., time query tool). It is recommended to pass parameters to improve tool call accuracy.
tool_choice
default:auto

Tool selection strategy. Default: auto. To force a specific tool call method for a type of question (e.g., always use a tool or disable all tools), set this parameter.

Values:

  • auto: The model autonomously selects the tool strategy;
  • none: If you do not want tool calls, set tool_choice to none;
  • {"type": "function", "function": {"name": "the_function_to_call"}}: If you want to force a specific tool call, set this parameter where the_function_to_call is the specified tool function name.

Thinking models do not support forcing a specific tool call.

Available options:
auto,
none,
required

Whether to enable web search. Default: false.

Values:

  • true: Enabled. If web search is not triggered after enabling, optimize the prompt or set forced_search in search_options to force search;
  • false: Disabled.

Enabling web search may increase token consumption.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"enable_search": True}.

response_format
object

Format of the response. Values:

  • {"type": "text"}: Returns text response;
  • {"type": "json_object"}: Returns a standard JSON string.

Related doc: Structured Output.

If set to {"type": "json_object"}, you must explicitly instruct the model to output JSON in the prompt, e.g., "Please output in JSON format", otherwise an error will occur.

top_k
integer
default:20

Specifies the number of candidate tokens for sampling during generation. Higher values produce more random output; lower values produce more deterministic output. If set to null or greater than 100, the top_k strategy is disabled and only the top_p strategy takes effect. The value must be an integer greater than or equal to 0. Default: 20.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"top_k":xxx}.

Required range: x >= 0
repetition_penalty
number
default:1.05

Controls the repetition degree in continuous sequences during model generation. Increasing repetition_penalty reduces repetition; 1.0 means no penalty. No strict value range, as long as it is greater than 0.

repetition_penalty defaults:

  • qwen-max, qwen-math, qwen-vl-max, qwen-audio-turbo, QVQ, QwQ, Qwen3-VL: 1.0;
  • qwen-coder, qwen2-1.5b-instruct, qwen2-0.5b-instruct, qwen2.5-omni-7b: 1.1;
  • qwen-vl-plus: 1.2;
  • All other models: 1.05.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"repetition_penalty":xxx}.

Required range: x >= 0
presence_penalty
number
default:1.5

Controls content repetition during model generation.

Range: [-2.0, 2.0]. Positive values reduce repetition; negative values increase repetition.

For creative writing or brainstorming scenarios requiring diversity, fun, or creativity, it is recommended to increase this value; for technical documentation or formal text requiring consistency and terminology accuracy, it is recommended to decrease this value.

presence_penalty defaults:

  • 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), QVQ, qwen-max, qwen2.5-vl, qwen-vl-max, qwen-vl-plus, Qwen3-VL (non-thinking): 1.5;
  • qwen3-8b/14b/32b/30b-a3b/235b-a22b (thinking), qwen-plus/qwen-plus-latest/2025-04-28 (thinking), qwen-turbo/qwen-turbo/2025-04-28 (thinking): 0.5;
  • All others: 0.0.

Principle: When the parameter is positive, the model imposes a penalty on tokens already present in the current text (independent of frequency), reducing the probability of repeated occurrences, thereby reducing content repetition and increasing vocabulary diversity.

Required range: -2 <= x <= 2
max_completion_tokens
integer

Maximum length of model output, including thinking content and model response. Generation stops early when this value is exceeded, with finish_reason set to length.

Default and maximum values are the model's maximum output length.

Difference from max_tokens: max_completion_tokens limits the full model output (thinking + response), while max_tokens limits only the response portion. Thinking models recommend using max_completion_tokens.

Supported models:

  • Qianwen Max: Qwen3.7-Max and later models
  • Qianwen Plus: Qwen3.5-Plus and later models

The actual output token count may have an error of up to 10 tokens from the set max_completion_tokens value.

Required range: x >= 1
parallel_tool_calls
boolean
default:false

Whether to enable parallel tool calls. Default: false.

Values:

  • true: Enabled;
  • false: Disabled.
search_options
object

Strategy for web search.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"search_options": xxx}.

enable_thinking
boolean

When using mixed-thinking models (which can think or not think before responding), controls whether to enable thinking mode. Applies to Qwen3.7, Qwen3.6, Qwen3.5, Qwen3, Qwen3-Omni-Flash, Qwen3-VL models, and DeepSeek-V4-Pro/V4-Flash series (Aliyun direct supply), DeepSeek-V3.2/V3.2-exp/V3.1 series (Aliyun direct supply, SiliconFlow direct supply, Kuaishou Wanqing direct supply), Kimi-K2.7-code (thinking-only model), Kimi-K2.6/K2.5 series (Aliyun direct supply, Moonshot direct supply), GLM series. DeepSeek-V4 series enables thinking by default, adjustable via reasoning_effort.

Values:

  • true: Enabled. When enabled, thinking content is returned via the reasoning_content field.
  • false: Disabled.

Default values vary by supported model.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"enable_thinking": xxx}.

If not using the OpenAI SDK but calling directly via HTTP (such as curl), no extra_body is needed. Instead, place enable_thinking at the top level of the request body alongside model, messages, and other parameters, e.g., "enable_thinking": true.

thinking_budget
integer

Maximum number of tokens in the thinking process. Applies to Qwen3.7, Qwen3.6, Qwen3.5, Qwen3-VL, Qwen3, GLM (Aliyun direct supply), Kimi (Aliyun direct supply) series models. Related doc: Limiting Thinking Length.

Default value is the model's maximum thinking chain length. Refer to: Model List.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"thinking_budget": xxx}.

Required range: x >= 1
reasoning_effort
enum<string>

Controls the model's reasoning effort. Different models support different values and defaults.

DeepSeek-V4, GLM series and kimi/kimi-k3 (default: high):

  • Values: high (high reasoning effort), max (maximum reasoning effort). low and medium map to high, xhigh maps to max.
  • Applies to glm-5.2, glm-5.1, glm-5, deepseek-v4-pro, deepseek-v4-flash (Aliyun direct supply), kimi/kimi-k3 (Moonshot direct supply, max only).

qwen3.8-max-preview model (default: xhigh):

  • Values: xhigh (high reasoning effort), medium (medium reasoning effort), low (low reasoning effort). max maps to xhigh, high maps to xhigh, minimal maps to low, none maps to enable_thinking=False. Setting values other than these options and mappings will cause an error.

Important: qwen3.8-max-preview does not support setting reasoning_effort and thinking_budget simultaneously; setting both will cause an error. However, they support mutual conversion:

  • When thinking_budget is not set, reasoning_effort levels automatically map to thinking_budget: low corresponds to 4096, medium to 16384, xhigh to 262144.
  • When reasoning_effort is not set, thinking_budget automatically maps back to reasoning_effort: 04096 corresponds to low, 409716384 to medium, 16385~262144 to xhigh.
  • When neither is set, the default thinking_budget (131072) and default reasoning_effort (xhigh) are used.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"reasoning_effort": "high"}.

Available options:
low,
medium,
high,
max,
xhigh
tool_stream
boolean
default:false

Only takes effect when stream=true. Currently only Qwen and GLM series support this. Default: false.

Qwen series support list:

  • qwen-max series: text modality of qwen3.7-max series;
  • qwen-plus series: text modality of qwen3.7-plus and qwen3.6-plus series, and full modality of qwen3.5-plus series;
  • qwen-flash series: full modality of qwen3.7-flash, qwen3.6-flash, and qwen3.5-flash series.

Qwen series usage reference: tool_stream only affects complex tool parameters. Simple tool parameters will stream output as long as stream=true is enabled. Complex tools are tools where some parameter types are array or object.

  • tool_stream=false: Complex tool parameters are output at once, default behavior, complex format is more accurate;
  • tool_stream=true: Complex tool parameters are streamed output, no timeout risk for complex format.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"tool_stream": true}.

enable_code_interpreter
boolean
default:false

Whether to enable the code interpreter feature. Default: false.

Values:

  • true: Enabled;
  • false: Disabled.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"enable_code_interpreter": xxx}.

vl_high_resolution_images
boolean
default:false

Whether to increase the input image pixel limit to the pixel value corresponding to 16384 tokens. Related doc: Processing High-Resolution Images. Default: false.

When vl_high_resolution_images is true: Uses a fixed resolution strategy, ignoring the max_pixels setting. When the resolution is exceeded, the total image pixels are scaled down to this limit.

When vl_high_resolution_images is true, different models have different pixel limits:

  • Qwen3.7, Qwen3.6, Qwen3.5, Qwen3-VL series, qwen-vl-max, qwen-vl-max-0813, qwen-vl-plus, qwen-vl-plus-0815, qwen-vl-plus-0710: 16777216 (each token corresponds to 32×32 pixels, i.e., 16384×32×32);
  • QVQ series and other Qwen2.5-VL models: 12845056 (each token corresponds to 28×28 pixels, i.e., 16384×28×28).

When vl_high_resolution_images is false: The pixel limit is determined by max_pixels. When input image pixels exceed max_pixels, the image is scaled down to within max_pixels. The default pixel limit for each model is the default value of max_pixels.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"vl_high_resolution_images":xxx}.

n
integer
default:1

Number of responses, range 1-4. Only supported by certain models. Default: 1.

Required range: 1 <= x <= 4
logprobs
boolean
default:false

Whether to return log probabilities of output tokens. Default: false.

Values:

  • true: Return;
  • false: Do not return.

Content generated during the thinking phase (reasoning_content) does not return log probabilities.

Supported models:

  • Snapshot models of qwen-plus series (excluding stable models);
  • Snapshot models of qwen-turbo series (excluding stable models);
  • qwen3-vl-plus series models (including stable models);
  • qwen3-vl-flash series models (including stable models);
  • Qwen3 open-source models.
top_logprobs
integer
default:0

Specifies the number of candidate tokens with the highest probability for the model to return at each generation step. Default: 0.

Range: [0, 5].

Only takes effect when logprobs is true.

Required range: 0 <= x <= 5
preserve_thinking
boolean
default:false

Whether to concatenate historical assistant reasoning_content into model input. Suitable for scenarios requiring the model to reference historical thinking processes. Default: false.

Currently supported: qwen3.8-max-preview (enabled by default), qwen3.7-max, qwen3.7-max-2026-05-20 and later snapshots, qwen3.6-max-preview, qwen3.7-plus, qwen3.7-plus-2026-05-26, qwen3.6-plus, qwen3.6-plus-2026-04-02, qwen3.7-flash, qwen3.7-flash-2026-07-15, qwen3.6-flash, qwen3.6-flash-2026-04-16, kimi-k2.6 (Aliyun Bailian deployment), kimi-k2.7-code (Aliyun Bailian deployment, enabled by default), kimi/kimi-k2.7-code-highspeed (Moonshot direct supply, enabled by default), kimi/kimi-k2.7-code (Moonshot direct supply, enabled by default).

Important: When using qwen3.8-max-preview, preserve_thinking defaults to true and all historical reasoning_content must be passed back completely. Concatenating reasoning_content into the content field for playback is not supported. If historical messages do not contain reasoning_content, enabling this parameter will not cause errors and is compatible.

When enabled, historical reasoning_content counts toward input tokens and is billed accordingly.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"preserve_thinking": True}.

thinking
object

Controls thinking mode for MiniMax/MiniMax-M3 (supplied by 稀宇科技). Default: {"type":"adaptive"}. Non-standard parameter, use extra_body.

skill
object[]

Skill parameter for enabling specific generation skills (e.g., PPT generation). Only supported by qwen-doc-turbo model. Default: [].

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"skill": [...]}. When using skill, stream must be set to true.

Properties:

  • type (required): Skill type. Currently supports: ppt (PPT generation).
  • mode (optional): PPT generation mode. Values: general (default, template mode, requires template_id, generates HTML format PPT), creative (creative mode, no template needed, generates image-based PPT with each page as an image).
  • template_id (optional): PPT template ID. Used with mode=general or when mode is not set. Values: news_01 (news template), summary_01 (summary template), internet_01 (internet template), thesis_01 (thesis template).
clear_thinking
boolean
default:false

Controls whether historical reasoning_content (thinking process) is used as context input to the model in multi-turn conversations. Only supported by GLM series glm-5.2, glm-5.1, glm-5, glm-4.7 models. Default: false.

This parameter is not an OpenAI standard parameter. When calling through the Python SDK, place it in the extra_body object: extra_body={"enable_thinking": True,"clear_thinking": True}.

  • true: Ignores historical reasoning_content and uses only non-reasoning content such as visible text, tool calls and results as context input, which can reduce context length and cost;
  • false (default): Preserves historical reasoning_content and provides it to the model along with context. If Preserved Thinking is to be enabled, historical reasoning_content must be passed through completely, unmodified, and in original order in messages. Missing, truncation, rewriting, or reordering will cause degraded or ineffective results.
X-DashScope-DataInspection
string

Based on the content security capability of the Qianwen API, whether to further identify violations in input and output content. Values:

  • {"input":"cip","output":"cip"}: Further identification;
  • Not set: No further identification.

When calling via HTTP, place in the request header: -H "X-DashScope-DataInspection: {"input": "cip", "output": "cip"}";

When calling through the Python SDK, configure via extra_headers: extra_headers={'X-DashScope-DataInspection': '{"input":"cip","output":"cip"}'}.

Not supported via Node.js SDK.

Response

Success. Returns chat completions. Streaming returns SSE.

id
string

Unique identifier for this call.

object
string

Always chat.completion.

Example:

"chat.completion"

created
integer<int64>

Unix timestamp (seconds).

model
string

Model used for this request.

choices
object[]

Array of generated responses.

usage
object

Token usage information.

service_tier
string | null

Currently fixed to null.

system_fingerprint
string | null

Currently fixed to null.