Skip to main content

DashScope API Reference

You can call Qwen models using the DashScope API. This topic describes the input and output parameters and provides call examples.

  • China (Beijing)
  • Singapore
  • US (Virginia)
  • Germany (Frankfurt)
  • Japan (Tokyo)
  • Hong Kong (China)
HTTP request address:
  • Plain text models, such as qwen-plus: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation
  • Multimodal models, such as qwen3.7-plus or qwen3-vl-plus: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
The region configuration for SDK calls is as follows:
  • Python code
  • Java code
import os
import dashscope

# 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的region取值不同。
client = dashscope.Client(
    # 若没有配置环境变量,请用阿里云百炼API Key将下行替换为:api_key="sk-xxx"
    # 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)
Replace {WorkspaceId} with your actual Workspace ID. You must obtain an API key and configure it as an environment variable. If you use the DashScope SDK to make calls, you must also install the DashScope SDK.
Alibaba Cloud Model Studio has released workspace-specific domains for the China (Beijing), Singapore, and China (Hong Kong) regions. The new dedicated domains deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
  • China (Beijing): from https://dashscope.aliyuncs.com to https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
  • Singapore: from https://dashscope-intl.aliyuncs.com to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
{WorkspaceId} is your workspace ID, which can be found on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domain remains fully functional.

Request body

modelstring(Required)The name of the model to use.Supported models include Qwen large language models (commercial and open source editions), Qwen-VL, Qwen-Coder, Qwen-Audio, math models, DeepSeek (provided by Alibaba Cloud and SiliconFlow), Kimi (provided by Alibaba Cloud), GLM (provided by Alibaba Cloud), and MiniMax (provided by Alibaba Cloud and MiniMax).For specific model names and billing details, seeSelect a model.messagesarray(Required)The context to pass to the large language model (LLM), arranged in conversational order.
When you call over HTTP, place messages in the input object.
System Messageobject (Optional)A system message that is used to set the role, tone, task objectives, or constraints for the LLM. It is usually placed first in the messages array.
We do not recommend that you set a system message for QwQ models. A system message does not take effect for QVQ models.
contentstring(Required)The content of the message.rolestring(Required)The role for the system message. The value is fixed to system.
User Messageobject(Required)A user message that is used to pass questions, instructions, or context to the model.
contentstring or array(Required)The content of the message. If the input is only text, this parameter is a string. If the input includes multimodal data, such as images, or if explicit caching is enabled, this parameter is an array.
textstring(Required)The input text.imagestring (Optional)The image file for image understanding. You can pass an image in one of the following three ways:
  • Public URL: A publicly accessible image link.
  • Base64 encoding of the image, in the format data:image/<format>;base64,<data>.
  • Local file: The absolute path of a local file.
Applicable models: Qwen-VL, QVQExample: {"image":"https://xxxx.jpeg"}detail string (Optional)Image processing detail. Max, Plus, and Flash models support this parameter starting with Qwen4. The default is high.When max_pixels is omitted:
  • high: Process at the original resolution, up to 16777216 pixels.
  • low: Limit the image to 2621440 pixels.
  • auto: Same as low.
An explicit max_pixels value overrides the pixel limit selected by detail. The maximum is 16777216. In Chat Completions, place max_pixels alongside image_url; in DashScope, place it alongside image.For high-resolution images, high typically uses more input tokens than low.For Chat Completions, detail can be passed within image_url or at the same level as image_url; for DashScope, it is passed at the same level as image.
{"image":"https://example.com/image.jpg","detail":"high"}
videoarray or string (Optional)For Qwen4-Max, Qwen3.8, Qwen3.7, Qwen3.6, and Qwen3.5 series models, video input as a public URL image list supports 4–8000 images; Base64 image lists support up to 250 images.The video to pass when you use a Qwen-VL or QVQ model.
  • If you pass an image list, the type is array.
  • If you pass a video file, the type is string.
To pass a local file, see Local file.Examples:
  • Image list: {"video":["https://xx1.jpg",...,"https://xxn.jpg"]}
  • Video file: {"video":"https://xxx.mp4"}
fpsfloat(Optional)The number of frames to extract per second. The value must be in the range of [0.1, 10]. The default value is 2.0.
fps has two functions:
  • When a video file is the input, this parameter controls the frame extraction frequency. One frame is extracted every f p s 1 ​ seconds.
    This applies to Qwen-VL and QVQ models.
  • It informs the model of the time interval between adjacent frames, which helps the model better understand the video's temporal dynamics. This applies to both video file and image list inputs. This feature is suitable for scenarios such as event time localization or summarizing content by segment.
    This is supported by Qwen3.7, Qwen3.6, Qwen3.5, Qwen3-VL, Qwen2.5-VL, and QVQ models.
A larger fps value is suitable for high-speed motion scenarios, such as sports events and action movies. A smaller fps value is suitable for long videos or scenarios with relatively static content.
  • Pass in an image list: {"video":["https://xx1.jpg",...,"https://xxn.jpg"],"fps":2}
  • Pass in a video file: {"video": "https://xx1.mp4","fps":2}
max_framesinteger(Optional)The maximum number of frames that can be extracted from a video. If the number of frames calculated based on fps exceeds max_frames, the system automatically adjusts to extract frames uniformly within the max_frames limit. This ensures that the total number of frames does not exceed the limit.
  • qwen3.7 series, qwen3.6 series, qwen3.5 series: The maximum and default value is 8000.
  • qwen3-vl-plus series: The maximum and default value is 2000.
{"type": "video_url","video_url": {"url":"https://xxxx.mp4"},"max_frame": 2000}
When you call with an OpenAI-compatible API, you cannot customize the max_frames parameter. The API automatically uses the default value for each model.
min_pixelsinteger(Optional)Sets the minimum pixel threshold for the input image or video frames. If the total pixels of an input image or video frame are less than min_pixels, the image or frame is enlarged until its total pixels are higher than min_pixels.
  • Image input:
    • qwen4-max, Qwen3.7、Qwen3.6、Qwen3.5, Qwen3-VL: the default value and minimum value are both: 65536
    • Qwen2.5-VL open-source series and QVQ series models: the default value and minimum value are both 3136
  • Input video file or image list:
    • qwen4-max, qwen3-omni-flash, qwen3-vl-plus, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b, qwen3.5-397b-a17b, qwen3.5-flash, qwen3.5-flash-2026-02-23, qwen3.5-omni-flash, qwen3.5-omni-flash-2026-03-15, qwen3.5-omni-plus, qwen3.5-omni-plus-2026-03-15, qwen3.5-plus, qwen3.5-plus-2026-02-15, qwen3.5-plus-2026-04-20, qwen3.6-27b, qwen3.6-35b-a3b, qwen3.6-flash, qwen3.6-flash-2026-04-16, qwen3.6-plus, qwen3.6-plus-2026-04-02, qwen3.7-flash, qwen3.7-flash-2026-07-15, qwen3.7-max-2026-06-08, qwen3.7-plus, qwen3.7-plus-2026-05-26, qwen3.8-27b, qwen3.8-flash, qwen3.8-max, qwen3.8-max-0902, qwen3.8-omni-flash: Default value: 65536. Minimum value: 4096.
    • kimi-k2.5, kimi-k2.6, kimi-k2.7-code: Minimum value: 3136.
    • Qwen2.5-VL open source series, and QVQ series models: The default value is 50176, and the minimum value is 3136.
  • Image input: {"type": "image_url","image_url": {"url":"https://xxxx.jpg"},"min_pixels": 65536}
  • Video file input: {"type": "video_url","video_url": {"url":"https://xxxx.mp4"},"min_pixels": 65536}
  • Image list input: {"type": "video","video": ["https://xx1.jpg",...,"https://xxn.jpg"],"min_pixels": 65536}
max_pixelsinteger(Optional)Sets the maximum pixel threshold for the input image or video frames. If the total pixels of an input image or video are within the [min_pixels, max_pixels] range, the model recognizes the original image. If the total pixels of the input image are greater than max_pixels, the image is scaled down until the total pixels are below max_pixels.
  • Image input:
    • qwen4-max: Maximum value: 16777216. When omitted, images are processed according to detail. An explicit max_pixels value applies regardless of vl_high_resolution_images.
    Other models: The value of max_pixels depends on whether the vl_high_resolution_images parameter is enabled.
    • If vl_high_resolution_images is False:
      • Qwen3.7、Qwen3.6、Qwen3.5, Qwen3-VL: the default value is 2621440, and the maximum value is: 16777216
      • Qwen2.5-VL open-source series and QVQ series models: the default value is 1003520, and the maximum value is 12845056
    • If vl_high_resolution_images is True:
      • Qwen3.7、Qwen3.6、Qwen3.5, Qwen3-VL: max_pixels is invalid, and the maximum pixels of the input image is fixed at 16777216
      • Qwen2.5-VL open-source series and QVQ series models: max_pixels is invalid, and the maximum pixels of the input image is fixed at 12845056
  • Input video file or image list: When both min_pixels and max_pixels are set, max_pixels must be greater than or equal to min_pixels.
    • qwen4-max, qwen3-vl-plus, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b, qwen3.5-397b-a17b, qwen3.5-flash, qwen3.5-flash-2026-02-23, qwen3.5-omni-flash, qwen3.5-omni-flash-2026-03-15, qwen3.5-omni-plus, qwen3.5-omni-plus-2026-03-15, qwen3.5-plus, qwen3.5-plus-2026-02-15, qwen3.5-plus-2026-04-20, qwen3.6-27b, qwen3.6-35b-a3b, qwen3.6-flash, qwen3.6-flash-2026-04-16, qwen3.6-plus, qwen3.6-plus-2026-04-02, qwen3.7-flash, qwen3.7-flash-2026-07-15, qwen3.7-max-2026-06-08, qwen3.7-plus, qwen3.7-plus-2026-05-26, qwen3.8-27b, qwen3.8-flash, qwen3.8-max, qwen3.8-max-0902, qwen3.8-omni-flash: Default value: 655360. Maximum value: 2048000.
    • qwen3-omni-flash: Default value: 655360. Maximum value: 786432.
    • kimi-k2.5, kimi-k2.6, kimi-k2.7-code: Maximum value: 1568000.
    • Other Qwen3-VL open source models: The default value is 655360, and the maximum value is 786432.
    • Qwen2.5-VL open source series, and QVQ series models: The default value is 501760, and the maximum value is 602112.
  • Image input: {"type": "image_url","image_url": {"url":"https://xxxx.jpg"},"max_pixels": 8388608}
  • Video file input: {"type": "video_url","video_url": {"url":"https://xxxx.mp4"},"max_pixels": 655360}
  • Image list input: {"type": "video","video": ["https://xx1.jpg",...,"https://xxn.jpg"],"max_pixels": 655360}
total_pixelsinteger(Optional)The total pixel budget for frames sampled from a video.
  • 268435456: qwen4-max, qwen3.8-max、qwen3.8-max-0902。
  • 234881024:qwen3.5-plus、qwen3.5-plus-2026-02-15、qwen3.5-plus-2026-04-20、qwen3.6-plus、qwen3.6-plus-2026-04-02、qwen3.7-max-2026-06-08、qwen3.7-plus、qwen3.7-plus-2026-05-26。
  • 819200000:qwen3.5-122b-a10b、qwen3.5-27b、qwen3.5-35b-a3b、qwen3.5-397b-a17b、qwen3.5-flash、qwen3.5-flash-2026-02-23、qwen3.6-27b、qwen3.6-35b-a3b、qwen3.6-flash、qwen3.6-flash-2026-04-16、qwen3.7-flash、qwen3.7-flash-2026-07-15、qwen3.8-27b、qwen3.8-flash。
  • 184549376:qwen3.5-omni-flash、qwen3.5-omni-flash-2026-03-15、qwen3.5-omni-plus、qwen3.5-omni-plus-2026-03-15、qwen3.8-omni-flash。
  • 16777216:qwen3-omni-flash。
  • 102760448:kimi-k2.5、kimi-k2.6、kimi-k2.7-code。
  • 134217728:qwen3-vl-plus。
  • Video file input: {"type": "video_url","video_url": {"url":"https://xxxx.mp4"},"total_pixels": 134217728}
  • Image list input: {"type": "video","video": ["https://xx1.jpg",...,"https://xxn.jpg"],"total_pixels": 134217728}
audiostring
This is a required parameter for audio understanding models, such as qwen-audio-turbo.
The audio file to pass when you use the audio understanding feature.Example: {"audio":"https://xxx.mp3"}cache_controlobject(Optional)This is supported only by models that support explicit caching. It is used to enable explicit caching.
type string (Required)Fixed to ephemeral.
rolestring(Required)The role of the user message, fixed to user.
Assistant Message object (Optional)The model's reply to the user message.
contentstring (Optional)The message content. Optional only when the tool_calls parameter is specified in the assistant message.rolestring(Required)Fixed to assistant.partialboolean (Optional)Whether to enable partial mode. Related documentation and supported models: Partial mode.tool_calls array (Optional)After Function Calling is initiated, the returned tool and input parameter information, containing one or more objects. Obtained from the tool_calls field of the model response in the previous round.
id stringThe ID of the tool response.type stringThe tool type. Currently, only function is supported.function objectThe tool and input parameter information.
name stringThe tool name.arguments stringThe input parameter information, in JSON format string.
index integerThe index of the current tool information in the tool_calls array.
Tool Messageobject (Optional)The output information of the tool.
contentstring(Required)The output content of the tool function, which must be in string format.rolestring(Required)Fixed to tool.tool_call_idstring (Optional)The id returned after Function Calling is initiated, which can be obtained via response.output.choices[0].message.tool_calls[$index]["id"] and is used to identify the tool corresponding to the Tool Message.
temperaturefloat (Optional)The sampling temperature, which controls the diversity of the text generated by the model.A higher temperature value makes the generated text more diverse; conversely, a lower temperature value makes the generated text more deterministic.Value range: [0, 2)
  • qwen4-max: 1.0 in thinking mode, 0.7 in non-thinking mode.
  • qwen3.8-max/qwen3.8-flash (thinking mode): visual understanding 0.6, text input 1.0; temperature values below 0.6 are changed to 0.6 by default
  • (non-thinking mode), Qwen3.8 (non-thinking mode), Qwen3.7 (non-thinking mode), Qwen3.6 (non-thinking mode), Qwen3.5 (non-thinking mode), Qwen3 (non-thinking mode), Qwen3-Instruct series, Qwen3-Coder series, qwen-max series, qwen-plus series (non-thinking mode), qwen-flash series (non-thinking mode), qwen open-source series, qwen-coder series, qwen-doc-turbo, Qwen3-VL (non-thinking): 0.7;
  • QVQ series: 0.5;
  • qwen-audio-turbo series: 0.00001;
  • qwen-vl series: 0.01;
  • qwen-math series: 0;
  • Qwen3.7 (thinking mode), Qwen3.6 (thinking mode), Qwen3.5 (thinking mode), Qwen3 (thinking mode), Qwen3-Thinking, QwQ series: 0.6;
  • qwen-long series: 1.0;
  • qwen-plus-character: 0.92
  • Qwen3-VL (thinking mode): 0.8
  • DeepSeek series (directly supplied by Alibaba Cloud): deepseek-v4.1-flash, deepseek-v4-pro: 1.0; deepseek-r1-distill-qwen distilled version: 0.6;
  • DeepSeek series (directly supplied by SiliconFlow): siliconflow/deepseek-v3.2, siliconflow/deepseek-v3.1-terminus, siliconflow/deepseek-r1-0528, siliconflow/deepseek-v3-0324: 1.0;
  • DeepSeek series (directly supplied by Kuaishou Wanqing): vanchin/deepseek-v3.2-think (thinking mode): 0.6; vanchin/deepseek-v3.1-terminus: 0.7; vanchin/deepseek-v3.2-speciale, vanchin/deepseek-r1, vanchin/deepseek-v3, vanchin/deepseek-ocr: 1.0;
  • Kimi series (directly supplied by Alibaba Cloud): kimi-k2.7-code, kimi-k2.6 (thinking mode), kimi-k2.5 (thinking mode): 1.0; kimi-k2.6 (non-thinking mode), kimi-k2.5 (non-thinking mode): 0.6;
  • Kimi series (directly supplied by Moonshot): kimi/kimi-k3, kimi/kimi-k3.1-pro, kimi/kimi-k3.1-pro-highspeed, kimi/kimi-k2.7-code-highspeed, kimi/kimi-k2.7-code, kimi/kimi-k2.6 (thinking mode), kimi/kimi-k2.5 (thinking mode): 1.0; kimi/kimi-k2.6 (non-thinking mode), kimi/kimi-k2.5 (non-thinking mode): 0.6;
  • GLM series (directly supplied by Alibaba Cloud): glm-5.1, glm-5: 1.0;
  • GLM series (directly supplied by Zhipu): ZHIPU/GLM-5.1, ZHIPU/GLM-5: 0.6;
  • MiniMax series (directly supplied by Alibaba Cloud): MiniMax-M2.5: 1.0;
  • MiniMax series (directly supplied by Xiyu Technology): MiniMax/MiniMax-M3, MiniMax/MiniMax-M2.7, MiniMax/MiniMax-M2.5, MiniMax/MiniMax-M2.1: 1.0.
  • MiMo series (directly supplied by Xiaomi): mimo-v2.5-pro: 1.0, range [0, 1.5]; xiaomi/mimo-v2.6-pro-ultraspeed: 1.0, custom values are not supported; if other values are passed, 1.0 still applies.
When calling via HTTP, put temperature into the parameters object.
It is not recommended to change the default temperature value of QVQ models.
top_pfloat (Optional)The probability threshold for nucleus sampling, which controls the diversity of the text generated by the model.A higher top_p value makes the generated text more diverse. Conversely, a lower top_p value makes the generated text more deterministic.Value range: (0, 1.0].
  • qwen4-max: 0.95 in thinking mode, 0.8 in non-thinking mode.
(non-thinking mode), Qwen3.8 (non-thinking mode), Qwen3.7 (non-thinking mode), Qwen3.6 (non-thinking mode), Qwen3.5 (non-thinking mode), Qwen3 (non-thinking mode), Qwen3-Instruct series, Qwen3-Coder series, qwen-max series, qwen-plus series (non-thinking mode), qwen-flash series (non-thinking mode), Qwen 2.5 open-source series, qwen-coder series, qwen-long, qwen-doc-turbo, Qwen3-VL (non-thinking): 0.8;QVQ series: 0.5;qwen-math series: 1.0;(thinking mode), Qwen3.8 (thinking mode), Qwen3.7 (thinking mode), Qwen3.6 (thinking mode), Qwen3.5 (thinking mode), Qwen3 (thinking mode), Qwen3-VL (thinking mode), Qwen3-Thinking, QwQ series, qwen-plus-character: 0.95DeepSeek series (directly supplied by Alibaba Cloud): deepseek-v4-pro, deepseek-r1-distill-qwen distilled version: 0.95;DeepSeek series (directly supplied by SiliconFlow): siliconflow/deepseek-v3.2, siliconflow/deepseek-v3.1-terminus, siliconflow/deepseek-r1-0528, siliconflow/deepseek-v3-0324: 1.0;DeepSeek series (directly supplied by Kuaishou Wanqing): vanchin/deepseek-v3.2-think, vanchin/deepseek-v3.1-terminus: 0.95; vanchin/deepseek-v3.2-speciale: 0.9; vanchin/deepseek-r1: 0.8; vanchin/deepseek-v3, vanchin/deepseek-ocr: 1.0;Kimi series (directly supplied by Alibaba Cloud): kimi-k2.7-code, kimi-k2.6, kimi-k2.5: 0.95;Kimi series (directly supplied by Moonshot): kimi/kimi-k3, kimi/kimi-k3.1-pro, kimi/kimi-k3.1-pro-highspeed, kimi/kimi-k2.7-code-highspeed, kimi/kimi-k2.7-code, kimi/kimi-k2.6, kimi/kimi-k2.5: 0.95;GLM series (directly supplied by Alibaba Cloud): 0.95;GLM series (directly supplied by Zhipu): ZHIPU/GLM-5.1, ZHIPU/GLM-5: 0.95;MiniMax series (directly supplied by Alibaba Cloud): MiniMax-M2.5: 0.95;MiniMax series (directly supplied by Xiyu Technology): MiniMax/MiniMax-M3: 0.95; MiniMax/MiniMax-M2.7, MiniMax/MiniMax-M2.5, MiniMax/MiniMax-M2.1: 0.9.MiMo series (directly supplied by Xiaomi): xiaomi/mimo-v2.5-pro: 0.95, range [0.01, 1.0]; xiaomi/mimo-v2.6-pro-ultraspeed: 0.95, custom values are not supported; if other values are passed, 0.95 still applies.
In the Java SDK, it is topP. When calling via HTTP, put top_p into the parameters object.
We do not recommend changing the default top_p value of the QVQ model.
top_kinteger (Optional)The size of the candidate set sampled during generation. For example, when set to 50, only the 50 highest-scoring tokens in a single generation form the candidate set for random sampling. A larger value increases the randomness of generation; a smaller value increases the determinism. A value of None, or a top_k greater than 100, means the top_k policy is disabled, and only the top_p policy takes effect.The value must be greater than or equal to 0.
QVQ series: 10;QwQ series: 40;qwen-math series and qwen-audio-turbo series: 1;All other models: 20;GLM series (Alibaba Cloud direct): 20;DeepSeek/Kimi/MiniMax series do not support the top_k parameter.
In the Java SDK, it is topK. When calling via HTTP, put top_k in the parameters object.
We do not recommend changing the default top_k value of the QVQ model.
enable_thinking boolean (Optional)Whether to enable thinking mode when using hybrid thinking models. Applicable to Qwen4, Qwen3.8, Qwen3.7, Qwen3.6, Qwen3.5, Qwen3, and Qwen3-VL models, as well as the DeepSeek-V4-Pro/V4-Flash series (Alibaba Cloud direct), DeepSeek-V3.2/V3.2-exp/V3.1 series (Alibaba Cloud direct, SiliconFlow direct), Kimi-K2.6/K2.5 series (Alibaba Cloud direct), and GLM series. The DeepSeek-V4 series enables thinking by default, and you can adjust the reasoning effort via the reasoning_effort parameter.Valid values:
  • true: Enable
    When enabled, the thinking content is returned via the reasoning_content field.
  • false: Disable
Default values for different models: Supported models
In the Java SDK, it is enableThinking; when calling via HTTP, put enable_thinking in the parameters object.
thinking_display string (Optional)qwen4-max: "summarized". Chain-of-thought summary and encryption.By default, the complete chain-of-thought is returned. After this feature is enabled, the original chain-of-thought is no longer returned in plaintext; instead, a summary and the complete ciphertext are returned. The summary is for display, and the ciphertext is for recovering historical thinking.preserve_thinking boolean (Optional) The default value is false (qwen4-max, qwen3.8-max/qwen3.8-flash default value is true)Whether to append the reasoning_content of assistant messages in the conversation history to the model input. Applicable to scenarios where the model needs to refer to the historical thinking process.kimi/kimi-k3.1-pro and kimi/kimi-k3.1-pro-highspeed support this parameter, and it is disabled by default.Currently supported: qwen4-max, qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash (enabled by default), qwen3.7-max, qwen3.7-max-2026-05-20 and subsequent snapshots, 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 (deployed on Alibaba Cloud Model Studio), kimi-k2.7-code (deployed on Alibaba Cloud Model Studio, enabled by default), kimi/kimi-k2.7-code-highspeed (Moonshot direct, enabled by default), kimi/kimi-k2.7-code (Moonshot direct, enabled by default).
Important: When using qwen4-max or qwen3.8-max/qwen3.8-flash, preserve_thinking defaults to true, and you must pass back all reasoning_content from the conversation history in full. Appending reasoning_content to the content field when passing it back is not supported.
  • If the historical messages do not contain reasoning_content, enabling this parameter will not cause an error and is fully compatible.
  • When enabled, the reasoning_content in the conversation history counts toward the input token count and is billed.
When calling via HTTP, put preserve_thinking in the parameters object. The Java SDK is not supported yet.
thinking_budget integer (Optional)The maximum length of the thinking process. Applicable to Qwen4, Qwen3.8, Qwen3.7, Qwen3.6, Qwen3.5, Qwen3-VL, Qwen3, GLM (directly provided by Alibaba Cloud), and Kimi (directly provided by Alibaba Cloud) series models, among which kimi-k3 and kimi-k3.1-pro do not support this parameter. Related documentation: Limit thinking length. Default value: 131072 (qwen4-max).Other models: the default value is the model's maximum chain-of-thought length. See Select Model
For the Java SDK, it is thinkingBudget. When calling via HTTP, put thinking_budget in the parameters object.
Other models: the default value is the model's maximum chain-of-thought length.
reasoning_effort string (Optional)qwen4-maxDefault value: reasoning_effort=high.
reasoning_effortActual level
minimal, lowlow
medium, highhigh
xhigh, maxxhigh
noneThinking disabled
qwen4-max does not support setting both reasoning_effort and thinking_budget at the same time. thinking_budget must be a positive integer and cannot be set to 0.When only thinking_budget is set, the thinking level is determined according to the following table, and the passed-in budget value is retained.
thinking_budgetActual level
1–4096low
4097–131072high
131073–262144xhigh
When neither is set, high and 131072 are used.Controls the model's reasoning effort. Different models support different optional values and default values.kimi-k3.1-pro (deployed on Alibaba Cloud Model Studio): the default value is max.
  • max (default): deep reasoning
  • high: enhanced reasoning
  • medium: moderate reasoning
  • low: light reasoning
enable_thinking defaults to true. You can set it to false to disable thinking, but it is recommended to keep it enabled, as disabling it significantly affects the model output quality.DeepSeek-V4 and GLM series (default value is high)Valid values:
  • high: high-effort reasoning
  • max: maximum-effort reasoning
low and medium are mapped to high, and xhigh is mapped to max.Applicable to glm-5.2, glm-5.1, glm-5, deepseek-v4.1-flash, and deepseek-v4-pro (excluding deepseek-v4-flash-0731)kimi/kimi-k3, kimi/kimi-k3.1-pro, kimi/kimi-k3.1-pro-highspeed (directly provided by Moonshot AI) (default value is max, only max is supported)Valid values:
  • max: maximum-effort reasoning
For glm-5.3, ZHIPU/GLM-5.3, ZHIPU/GLM-5.3-Flash, ZHIPU/GLM-5.3-FlashX, and kimi-k3 (directly provided by Alibaba Cloud) models: the default value ismaxValid values:
  • max (default): deep reasoning
  • high: enhanced reasoning
  • low: light reasoning
This model always has thinking enabled. enable_thinking only supports true, and passing false will cause the API request to fail.For the deepseek-v4-flash-0731 and deepseek-v4-pro-0813 models: the default value ishighValid values:
  • max: maximum-effort reasoning
  • high (default): high-effort reasoning
  • low: low-effort reasoning
For compatibility considerations, medium is mapped to high, and xhigh is mapped to high.For qwen3.8 series models: the default value isxhighValid values:
  • xhigh (default): high-effort reasoning
  • medium: medium-effort reasoning
  • low: low-effort reasoning
max maps to xhigh, high maps to xhigh, minimal maps to low, and none maps to enable_thinking=False.
Setting values other than the optional values and mapping values above will cause an error.
Important: The qwen3.8 series does not support setting reasoning_effort and thinking_budget at the same time; setting both will cause an error. However, the two support mutual conversion:
  • When thinking_budget is not set, reasoning_effort levels automatically map to thinking_budget: low corresponds to 4096, medium corresponds to 16384, and xhigh corresponds to 262144.
  • When reasoning_effort is not set, thinking_budget automatically maps back to reasoning_effort: 0~4096 corresponds to low, 4097~16384 corresponds to medium, and 16385~262144 corresponds to xhigh.
  • When neither is set, the default thinking_budget (131072) and default reasoning_effort (xhigh) are used.
When calling via HTTP, put reasoning_effort into the parameters object.
tool_stream boolean (optional) The default value is falseIt only affects the streaming output behavior of complex tool parameters and takes effect only in streaming calls. Ordinary tool parameters (all parameter types are string) are streamed as long as streaming is enabled, and tool_stream has no effect on them. Complex tools refer to tools whose definitions contain parameters of the array or object type. Currently, only the Qwen and GLM series support this.Supported Qwen series:
  • qwen-max series: the text modality of qwen4-max, qwen3.8-max series, and qwen3.7-max series
  • qwen-plus series: the text modality of qwen3.7-plus series and qwen3.6-plus series, and the omni-modality of qwen3.5-plus series
  • qwen-flash series: the omni-modality of qwen3.8-flash series, qwen3.7-flash series, qwen3.6-flash series, and qwen3.5-flash
Usage reference for the Qwen series:
  • tool_stream=false: complex tool parameters are output all at once; this is the default behavior and complex formats are more accurate.
  • tool_stream=true: complex tool parameters are streamed, with no timeout risk for complex formats.
Complex tools refer to tools whose definitions contain parameters of the array or object type.
Supported GLM series: glm-5 and glm-5.1 (directly provided by Alibaba Cloud).Usage reference for the GLM series:
  • tool_stream=false: tool parameters are output all at once; this is the default behavior and complex formats are more accurate.
  • tool_stream=true: tool parameters are streamed, with no timeout risk for complex formats.
When calling via HTTP, put tool_stream into the parameters object.
enable_code_interpreter boolean (optional) The default value is falseWhether to enable the code interpreter feature. Related documentation: Code InterpreterValid values:
  • true: Enable
  • false: Do not enable
The Java SDK is not supported. When calling via HTTP, put enable_code_interpreter into the parameters object.
clear_thinkingboolean (optional) The default value is falseUsed to control whether the reasoning_content (thinking process) of historical turns is provided to the model as context in multi-turn conversations. Only the GLM series models glm-5.3, glm-5.2, glm-5.1, and glm-5 support this. The default value is true for glm-5.3 and false for the other models.
  • true: Enable. Ignores the reasoning_content of historical turns 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): Do not enable. Retains the reasoning_content of historical turns and provides it to the model together with the context. To enable Preserved Thinking, you must pass the historical reasoning_content through in messages completely, unmodified, and in the original order; missing, trimmed, rewritten, or reordered content will degrade the effect or prevent it from working.
repetition_penaltyfloat (optional)The repetition degree of consecutive sequences in model generation. Increasing repetition_penalty can reduce the repetition degree of model output, and 1.0 means no penalty. There is no strict value range; it only needs to be greater than 0.
  • qwen4-max, qwen-max, qwen-math series, qwen-audio-turbo series, QVQ series, QwQ series, Qwen3-VL: 1.0;
  • qwen-coder series: 1.1;
  • Other models: 1.05.
  • GLM series (directly provided by Alibaba Cloud): 1.0;
In the Java SDK, it is repetitionPenalty. When calling via HTTP, put repetition_penalty into the parameters object.
It is not recommended to change the default repetition_penalty value of QVQ models.
frequency_penalty float (Optional)Supported by qwen4-max. Applies a penalty based on the number of times a Token has already appeared, to adjust the generation of repeated content.presence_penaltyfloat(Optional)Controls the degree of content repetition when the model generates text.Value range: [-2.0, 2.0]. Positive values reduce repetition, and negative values increase it.In scenarios that call for diversity, fun, or creativity, such as creative writing or brainstorming, it is recommended to increase this value; in scenarios that emphasize consistency and terminology accuracy, such as technical documentation or formal texts, it is recommended to decrease this value.
qwen4-max (non-thinking mode), Qwen3.8 (non-thinking mode), Qwen3.7 (non-thinking mode), Qwen3.6 (non-thinking mode), Qwen3.5 (non-thinking mode), Qwen3 (non-thinking mode), Qwen3-Instruct series/1.7b/4b (thinking mode), QVQ series, qwen-max, qwen2.5-vl series, Qwen3-VL (non-thinking): 1.5;qwen-plus/qwen-plus-latest/2025-04-28 (thinking mode): 0.5;All others: 0.0.DeepSeek series (directly provided by Alibaba Cloud): deepseek-r1-distill-qwen distilled version: 1;Kimi series (directly provided by Alibaba Cloud): kimi-k2.7-code, kimi-k2.6, kimi-k2.5: 0.0;Kimi series (directly provided by Moonshot AI): 0.0;MiniMax series (directly provided by Alibaba Cloud): MiniMax-M2.5: 0.0;Other DeepSeek/Kimi/GLM/MiniMax models have no default value.
If the parameter value is positive, the model applies a penalty to Tokens that already exist in the current text (the penalty is independent of how many times the text has appeared), reducing the probability of these Tokens appearing again, thereby reducing content repetition and increasing word diversity.
Prompt: Translate this sentence into Chinese: "This movie is good. The plot is good, the acting is good, the music is good, and overall, the whole movie is just good. It is really good, in fact. The plot is so good, and the acting is so good, and the music is so good."Parameter value 2.0: This movie is good. The plot is great, the acting is great, the music is very pleasant, and overall the whole movie is just wonderful. In fact, it is truly excellent. The plot is so brilliant, the acting is outstanding, and the music is so melodious.Parameter value 0.0: This movie is good. The plot is good, the acting is good, the music is good, and overall the whole movie is good. In fact, it is really good. The plot is very good, the acting is very good, and the music is equally good.Parameter value -2.0: This movie is good. The plot is good, the acting is good, the music is good, and overall the whole movie is good. In fact, it is really good. The plot is very good, the acting is very good, and the music is very good.
It is not recommended to change the default presence_penalty value of QVQ models.
The Java SDK does not support setting this parameter*.* When calling over HTTP, put presence_penalty into the parameters object.
vl_high_resolution_imagesboolean(Optional) Default value is falseFor qwen4-max, even if vl_high_resolution_images=true, an explicitly passed max_pixels still takes effect.Whether to raise the pixel limit of input images to the pixel value corresponding to 16384 Tokens. Related documentation: Process high-resolution images.
  • vl_high_resolution_images:true, uses the fixed resolution policy, ignores the max_pixels setting, and when this resolution is exceeded, scales the total pixels of the image down to within this limit.
    When vl_high_resolution_images is True, different models have different pixel limits:
    • Qwen3.7 series, Qwen3.6 series, Qwen3.5 series, and Qwen3-VL series models: 16777216 (each Token corresponds to 32*32 pixels, i.e., 16384*32*32)
    • QVQ series and other Qwen2.5-VL series 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; if the pixels of the input image exceed max_pixels, the image will be scaled down to within max_pixels. The default pixel limit of each model is the default value of max_pixels.
In the Java SDK, it is vlHighResolutionImages (minimum required version is 2.20.8). When calling via HTTP, put vl_high_resolution_images in the parameters object.
vl_enable_image_hw_outputboolean (optional), default value is falseWhether to return the dimensions of the scaled image. The model scales input images; when set to True, the height and width of the scaled image are returned. When streaming output is enabled, this information is returned in the last chunk. Supports Qwen-VL models.
In the Java SDK, it is vlEnableImageHwOutput, and the minimum Java SDK version is 2.20.8*.* When calling via HTTP, put vl_enable_image_hw_output in the parameters object.
max_tokensinteger (optional, to be deprecated soon)
This parameter will be deprecated soon; for new integrations, use max_completion_tokens.
The meaning of this parameter varies by model, as follows:
  • deepseek-v4.1-flash, deepseek-v4-pro, deepseek-v4-pro-0813, deepseek-v4-flash-0731: the maximum number of tokens for the model response plus the chain-of-thought. When the model output exceeds this value, generation stops early and the returned finish_reason is length.
  • qwen4-max: the maximum number of tokens (sum of thinking and final response). max_tokens is equivalent to max_completion_tokens; when this limit is exceeded, generation stops early and finish_reason is length.
  • glm-5.3: max_tokens is the maximum number of tokens for the model response plus the chain-of-thought; when the model output exceeds this value, generation stops early and the returned finish_reason is length. glm-5.3 ignores the thinking_budget parameter.
  • glm-5.2: when the thinking_budget parameter is not passed, max_tokens is the maximum number of tokens for the model response plus the chain-of-thought; when the model output exceeds this value, generation stops early and the returned finish_reason is length; when thinking_budget is passed, max_tokens is only the maximum number of tokens for the model response, and the token count of the chain-of-thought is controlled separately by thinking_budget.
  • Other models: the maximum number of tokens of the model response (excluding the chain-of-thought). If the generated content exceeds this value, generation stops early and the returned finish_reason is length.
The default and maximum values of GLM models are shown in the following table; for other models, both the default and maximum values are the model's maximum output length.
Supply methodModelDefault valueMaximum value
Alibaba Cloud directglm-5.3, glm-5.2, glm-5.2-fast-preview, glm-5.1, glm-565536131072
ZHIPU directZHIPU/GLM-5.3, ZHIPU/GLM-5.3-Flash, ZHIPU/GLM-5.3-FlashX, ZHIPU/GLM-5.2, ZHIPU/GLM-5.1, ZHIPU/GLM-565536131072
In the Java SDK, it is maxTokens (for Qwen VL/Audio models, it is maxLength, and versions after 2.18.4 also support setting it to maxTokens). When calling via HTTP, put max_tokens in the parameters object.
max_completion_tokensinteger (optional)The maximum length of the model output, including the chain-of-thought and the model response. When the model output exceeds this value, generation stops early and the returned finish_reason is length.For GLM models, see the table in the max_tokens parameter for the default and maximum values; for other models, both the default and maximum values are the model's maximum output length.Difference from max_tokens: max_completion_tokens always limits the model's complete output (chain-of-thought + response); the specific limit of max_tokens varies by model and thinking_budget settings, see the descriptions above. For thinking models, max_completion_tokens is recommended.The following models are supported:
  • Qwen Max: Qwen3.7-Max and later models
  • Qwen Plus: Qwen3.5-Plus and later models
  • Qwen Flash: Qwen3.5-Flash and later models
  • Kimi: kimi-k2.5 and later Kimi models
  • GLM: the Alibaba Cloud direct and ZHIPU direct models listed in the table above
  • MiniMax: MiniMax-M2.5 and later MiniMax models
  • DeepSeek: deepseek-v4-pro and later DeepSeek models
Except for the ZHIPU direct GLM models listed in the table above, none of the above models include other third-party direct-supply models.
There may be a discrepancy of up to 10 tokens between the actual number of output tokens and the set max_completion_tokens value.
The Java SDK does not currently support this parameter. When calling via HTTP, put max_completion_tokens in the parameters object.
seedinteger (optional)Random number seed. Used to ensure that generation results are reproducible under the same input and parameters. If the same seed is passed on each call with other parameters unchanged, the model will return the same result as much as possible.Value range: [0,2 31 −1].
For all other models, it is 1234.
When calling via HTTP, put seed in the parameters object.
streamboolean (optional), default value is falseWhether to stream the response. Parameter values:
  • false: The model returns the complete result in one pass after generating all content.
  • true: Outputs while generating, i.e., each time a portion of content is generated, a fragment (chunk) is output immediately.
This parameter is supported only by the Python SDK. To enable streaming output with the Java SDK, call the streamCall interface; to enable streaming output over HTTP, set X-DashScope-SSE to enable in the Header.
Qwen3 commercial models (thinking mode), Qwen3 open-source models, QwQ, and QVQ support streaming output only.
incremental_outputboolean (optional) Default is false (the default value is true for Qwen3-Max, Qwen3-VL, Qwen3 open-source models, QwQ, and QVQ models)Whether to enable incremental output in streaming mode. We recommend setting it to true first.
Python SDK 2.0 returns increments by default during streaming output (incremental_output defaults to true), so this parameter does not need to be set.
Parameter values:
  • false: Each output is the entire sequence generated so far, and the last output is the complete generated result.
I
I like
I like apple
I like apple.
  • true (recommended): Incremental output, i.e., subsequent output does not include content already output. You need to read these fragments one by one in real time to obtain the complete result.
I
like
apple
.
In the Java SDK, this is incrementalOutput. When calling via HTTP, put incremental_output into the parameters object.
QwQ models and Qwen3 models in thinking mode support only true. Since the default value for Qwen3 commercial models is false, you need to manually set it to true in thinking mode.
Qwen3 open-source models do not support setting this parameter to false.
response_formatobject (optional) Default value is {"type": "text"}The format of the returned content. Valid values:
  • {"type": "text"}: Outputs a text reply;
  • {"type": "json_object"}: Outputs a JSON string in standard format.
  • {"type": "json_schema", "json_schema": {...}}: Outputs a JSON string that strictly conforms to the specified JSON Schema, allowing precise control over the output structure and field types.
Related documentation: Structured output. The models supported by json_object and json_schema differ; see Supported models.
If you specify {"type": "json_object"}, you must explicitly instruct the model in the prompt to output JSON, such as "Please output in json format"; otherwise an error will occur. If you specify {"type": "json_schema", ...}, the prompt does not need to contain the JSON keyword.
In the Java SDK, this is responseFormat*.* When calling via HTTP, put response_format into the parameters object.
typestring(Required)The format of the returned content. Valid values:
  • text: Outputs a text reply;
  • json_object: Outputs a JSON string in standard format;
  • json_schema: Outputs a JSON string that strictly conforms to the structure defined by the json_schema field.
json_schemaobject (optional)Required when type is json_schema; it defines the JSON structure that the model output must follow. Related documentation: Obtain output in a specified format.
With the DashScope method, you must manually construct the JSON Schema; for the format and examples, see Obtain output in a specified format. The Java SDK is not supported yet.
namestring (required)The name of the Schema.schemaobject (required)The JSON Schema object that describes the output structure. Use properties to define the field structure, required to declare the list of mandatory fields, and additionalProperties to control whether fields not defined in the Schema are allowed in the output (recommended to set to false, i.e., only output defined fields). Supported data types: string, number, integer, boolean, object, array, enum. Related documentation: Configuration guide.strictboolean (optional)Whether to strictly follow the structure defined by schema. We recommend setting it to true.
result_formatstring (optional) Default is text (the default value is message for Qwen3-Max, Qwen3-VL, QwQ models, Qwen3 open-source models, and Qwen-Long models)The format of the returned data. We recommend setting it to message first, which makes it easier to have multi-turn conversations.
Python SDK 2.0 always returns the message format, so you do not need to set this parameter; this parameter only matters for HTTP API calls.
The platform will later change the default value to message uniformly.
In the Java SDK, this is resultFormat. When calling via HTTP, put result_format into the parameters object.
When the model is Qwen-VL/QVQ/Audio, setting text does not take effect.
Qwen3-Max, Qwen3-VL, and Qwen3 models in thinking mode can only be set to message. Since the default value for Qwen3 commercial models is text, you need to set it to message.
If you use the Java SDK to call Qwen3 open-source models and pass in text, the result is still returned in the message format.
logprobs boolean (Optional) Default value: falseWhether to return the log probabilities of output tokens. Valid values:
  • true Return
  • false Do not return
The following models are supported:
  • qwen4-max
  • Snapshot models in the qwen-plus series (excluding stable models)
  • qwen3-vl-plus series (including stable models)
  • Qwen3 open-source models
When calling via HTTP, put logprobs into the parameters object.
top_logprobs integer (Optional) Default value: 0Specifies the number of highest-probability candidate tokens returned by the model at each generation step.Value range: [0,5]Takes effect only when logprobs is true.
In the Java SDK, this is topLogprobs. When calling via HTTP, put top_logprobs into the parameters object.
ninteger (Optional) Default value: 1The number of responses to generate. Value range: 1-4. For scenarios that require multiple responses (such as creative writing and ad copy), you can set a larger n value.
kimi/kimi-k3.1-pro and kimi/kimi-k3.1-pro-highspeed do not support this parameter.
Currently, only qwen4-max, Qwen3 (non-thinking mode), and qwen-plus-character models are supported, and the value is fixed to 1 when the tools parameter is passed in.
Setting a larger n value does not increase input token consumption, but increases output token consumption.
When calling via HTTP, put n into the parameters object.
stopstring or array (Optional)Specifies stop words. When the text generated by the model contains a string or token_id specified by stop, generation stops immediately.You can pass in sensitive words to control the model's output.
When stop is an array, you cannot use both token_id and strings as elements at the same time; for example, you cannot specify ["hello",104307].
When calling via HTTP, put stop into the parameters object.
toolsarray (Optional)An array containing one or more tool objects for the model to call in Function Calling. Related documentation: Function CallingWhen using tools, you must set result_format to message.When initiating Function Calling or submitting tool execution results, you must set the tools parameter.
typestring(Required)The tool type. Currently, only function is supported.functionobject(Required)
namestring (required)The name of the tool function. It must consist of letters and digits, and can contain underscores and hyphens, with a maximum length of 64.descriptionstring(Required)The description of the tool function, which helps the model determine when and how to call the tool function.parametersobject(Optional) The default value is {}The parameter description of the tool, which must be a valid JSON Schema. For a description of JSON Schema, see link. If the parameters parameter is empty, it indicates that the tool has no input parameters (for example, a time query tool).
To improve the accuracy of tool calling, we recommend that you pass in parameters.
When calling via HTTP, put tools into the parameters object. The qwen-vl and qwen-audio series models are not supported for now.
tool_choicestring or object(Optional) The default value is autoThe tool selection policy. If you need to force a specific tool calling behavior for certain types of questions (for example, always using a specific tool or disabling all tools), you can set this parameter.
  • auto The large model autonomously selects the tool strategy;
  • none If you want to temporarily disable tool calling in a specific request, set the tool_choice parameter to none;
  • required If you want to force at least one tool to be called, set the tool_choice parameter to required, and the model will always return tool calling information.
    The Qwen series models do not support required for now: in non-thinking mode, tool calling cannot be guaranteed, and in thinking mode, required is currently not supported.
  • {"type": "function", "function": {"name": "the_function_to_call"}} If you want to force a specific tool to be called, set the tool_choice parameter to {"type": "function", "function": {"name": "the_function_to_call"}}, where the_function_to_call is the name of the specified tool function.
    Models in thinking mode do not support forcing a specific tool to be called.
In the Java SDK, it is toolChoice. When calling via HTTP, put tool_choice into the parameters object.
parallel_tool_calls boolean (Optional) The default value is falseWhether to enable parallel tool calling.
kimi/kimi-k3.1-pro and kimi/kimi-k3.1-pro-highspeed do not support this parameter.
Valid values:
  • true: Enable
  • false: Do not enable.
For details about parallel tool calling, see Parallel tool calling.
In the Java SDK, it is parallelToolCalls. When calling via HTTP, put parallel_tool_calls into the parameters object.
enable_searchboolean(Optional) The default value is falseWhether the model uses internet search results as reference when generating text. Valid values are as follows:
  • true: Enable internet search. The model uses the search results as reference information during text generation, but the model determines whether to use internet search results based on its internal logic.
    If no internet search occurs after enabling this feature, you can optimize the prompt or set the forced_search parameter in search_options to enable forced search.
  • false: Disable internet search.
For billing information, see Billing Details.
In the Java SDK, this is enableSearch. When calling through HTTP, put enable_search into the parameters object.
Enabling the Internet search function may increase Token consumption.
search_optionsobject (optional)The policy for web search. Only takes effect when enable_search is true. For more information, see Web search.
When calling through HTTP, put search_options into the parameters object. In the Java SDK, this is searchOptions.
enable_sourceboolean (optional) The default value is falseWhether to display the retrieved search results in the response. Parameter values:
  • true: Displayed;
  • false: Not displayed.
enable_citation boolean (optional) The default value is falseWhether to enable corner marker annotation in the [1] or [ref_1] style. Takes effect when enable_source is true. Parameter values:
  • true: Enabled;
  • false: Disabled.
citation_format string (optional) The default value is "[<number>]"The corner marker style. Takes effect when enable_citation is true. Parameter values:
  • [<number>]: The corner marker takes the form of [1];
  • [ref_<number>]: The corner marker takes the form of [ref_1].
forced_search boolean (optional) The default value is falseWhether to forcibly enable search. Parameter values:
  • true: Forcibly enabled;
  • false: Not forcibly enabled.
search_strategy string (optional) The default value is turboThe policy for searching Internet information.Valid values:
  • turbo (default): Balances response speed and search performance, suitable for most scenarios.
  • max: Adopts a more comprehensive search strategy that can call multiple search engines to obtain more thorough search results, but the response time may be longer.
  • agent: Can call the web search tool and the large model multiple times to perform multi-round information retrieval and content consolidation.
    This policy applies only to the non-thinking mode of qwen3.7-max, qwen3.7-max-2026-05-20, qwen3.5-plus, qwen3.5-plus-2026-02-15, qwen3.5-flash, and qwen3.5-flash-2026-02-23 (streaming only).
    If this strategy is enabled, only returning search sources (enable_source: true) is supported. Other web search features are not available. enable_search_extension boolean (Optional) The default value is false.
Specifies whether to enable domain-specific enhancement. The valid values are:
  • true Enabled.
  • false (default) Disabled.
prepend_search_result boolean (Optional) The default value is false.In streaming output with enable_source set to true, you can use prepend_search_result to configure whether the first returned data packet contains only search source information. The valid values are:
  • true Provides only the search source.
  • false (default) Contains information from the search source and the response from the LLM.
The DashScope Java SDK is not currently supported.
X-DashScope-DataInspectionstring (Optional)In addition to the content moderation capabilities of the Qwen API, you can use the AI guardrail to further identify non-compliant information in the input and output content. The value is a JSON string. input and output correspond to the input and output. When a field is set to cip, the AI guardrail further inspects content in that direction. The two fields can be set separately:
  • '{"input":"cip","output":"cip"}': The AI guardrail further inspects both the input and output.
  • '{"input":"cip"}': The AI guardrail further inspects the input only.
  • '{"output":"cip"}': The AI guardrail further inspects the output only.
  • Do not set this parameter: The AI guardrail is not enabled.
When you call over HTTP, place it in the request header: -H "X-DashScope-DataInspection: {\"input\": \"cip\", \"output\": \"cip\"}".When you call with the Python SDK, configure it using headers: headers={'X-DashScope-DataInspection': '{"input":"cip","output":"cip"}'}.For detailed usage, see Input and output AI safety guardrails. To enable the guardrail without modifying your calling code, use the workspace-level switches.
This is not supported by the Java SDK.
This is not applicable to Qwen-Audio series models.
skillarray(Optional)The skill parameter, which is used to enable specific generation skills, such as PPT generation. Only the qwen-doc-turbo model supports this. For more information, see Generate a PPT.
When you call over HTTP, place skill in the parameters object.
When using skill, stream must be set to true.
typestring(Required)The skill type. The currently supported value is:
  • ppt: PPT generation.
modestring (Optional)The PPT generation mode. The valid values are:
  • general (default): Template mode. This must be used with template_id to generate a PPT in HTML format.
  • creative: Creative mode. No template is required. This generates a graphic-based PPT where each page is an image.
template_idstring (Optional)The PPT template ID. This is used if mode is general or if mode is not set. The valid values are:
  • news_01: News template
  • summary_01: Summary template
  • internet_01: Internet template
  • thesis_01: Thesis template
  • Text input
  • Streaming output
  • Image input
  • Video input
  • Tool calling
  • Asynchronous invocation
  • Document understanding
  • PPT generation
  • Python
  • Java
  • PHP(HTTP)
  • Node.js(HTTP)
  • C#(HTTP)
  • Go(HTTP)
  • curl
  • dashscope CLI
import os
import dashscope

# 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的region取值不同。
client = dashscope.Client(
    # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
    # 各地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
    api_key=os.getenv('DASHSCOPE_API_KEY'),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

messages = [
    {'role': 'system', 'content': [{'text': 'You are a helpful assistant.'}]},
    {'role': 'user', 'content': [{'text': '你是谁?'}]}
]
response = client.multimodal.chat.create(
    # 此处以qwen4-max为例,可按需更换模型名称。模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
    model="qwen4-max",
    messages=messages,
    )
print(response)

Chat response object (streaming and non-streaming output formats are consistent)

request_idstringThe unique ID for this call.
The Java SDK returns the parameter as requestId.
codestringThe error code. Returned when the call fails.
When a Python SDK 2.0 call fails, it does not return envelope fields; instead, it throws a DashScopeError (e.code/e.status_code/e.message/e.request_id).
outputobjectThe information about the call result.
textstringThe reply that is generated by the model. If the input parameter result_format is set to text, the reply content is returned in this field.finish_reasonstringThis parameter is not empty if the input parameter result_format is set to text.This can occur in the following four situations:
  • null while generating
  • stop if the model output ends naturally or triggers a stop condition in the input parameters
  • length if the generation ends because the generated content is too long
  • tool_calls if a tool call occurs
choicesarrayThe model output information. The choices parameter is returned when result_format is message.
finish_reasonstringThis can occur in the following four situations:
  • null while generating
  • stop if the model output ends naturally or triggers a stop condition in the input parameters
  • length if the generation ends because the generated content is too long
  • tool_calls if a tool call occurs
messageobjectThe message object that is output by the model.
rolestringThe role of the output message, fixed as assistant.contentstring or arrayThe content of the output message. This is an array if you use qwen-vl or qwen-audio series models, and a string in other cases.
If function calling is initiated, this value is empty.
textstringThe content of the output message if you use qwen-vl or qwen-audio series models.image_hwarrayWhen the vl_enable_image_hw_output parameter is enabled for Qwen-VL series models, there are two cases:
  • Image input: Returns the height and width of the image in pixels.
  • Video input: Returns an empty array.
encrypted_content stringqwen4-max, thinking_display="summarized": Send the enabling parameter in every turn. Echo encrypted content unchanged; do not read, truncate, re-encode, modify, or concatenate it across turns. A summary cannot replace reasoning history. Thinking summary and encryption.reasoning_content stringThe model's deep thinking content.tool_callsarrayIf the model needs to call a tool, the tool_calls parameter is generated.
functionobjectThe name of the tool that is being called and its input parameters.
namestringThe name of the tool that is being called.argumentsstringThe parameters to be input into the tool, as a JSON string.
Due to the randomness of the LLM's response, the output JSON string may not always satisfy your function. We recommend that you validate the parameters before you input them into the function.
index integerThe index of the current tool_calls object in the tool_calls array.id stringThe ID of this tool response.type stringThe tool type, which must be function.
logprobsobjectThe probability information of the current choices object.
content arrayAn array of tokens with log probability information.
token stringThe current token.bytes arrayA list of the raw UTF-8 bytes of the current token. This is useful for accurately reconstructing the output content, especially when you handle emojis and Chinese characters.logprob floatThe log probability of the current token. A null value indicates an extremely low probability.top_logprobs arrayThe most likely tokens at the current token position and their log probabilities. The number of elements is consistent with the input parameter top_logprobs.
token stringThe current token.bytes arrayA list of the raw UTF-8 bytes of the current token. This is useful for accurately reconstructing the output content, especially when you handle emojis and Chinese characters.logprob floatThe log probability of the current token. A null value indicates an extremely low probability.
search_infoobjectThe information that is searched on the web. This parameter is returned after you set the search_options parameter.
search_resultsarrayThe results that are searched on the web.
site_namestringThe name of the website from which the search result originated.iconstringThe URL of the source website's icon. If there is no icon, this is an empty string.indexintegerThe serial number of the search result, which indicates its index in search_results.titlestringThe title of the search result.urlstringThe link address of the search result.
extra_tool_infoarrayThe domain-specific enhancement information that is returned after you enable the enable_search_extension parameter.
resultstringThe domain-specific enhancement tool output information.toolstringThe tool that is used for domain-specific enhancement.
usagemapThe token information for this chat request.
input_tokens integerThe length of the user input content after it is converted to tokens. For more information, see Additional information.output_tokens integerThe length of the model output content after it is converted to tokens.input_tokens_details object (Optional)Details of the length of the input content after it is converted to tokens.
text_tokens integer (Optional)The length of the input text after it is converted to tokens.image_tokens integer (Optional)The length of the input image after it is converted to tokens.video_tokens integer (Optional)The length of the input video file or image list after it is converted to tokens.
total_tokens integerThis field is returned when the input is plain text, and is the sum of input_tokens and output_tokens.image_tokens integerThis field is returned if the input content includes an image. It is the length of the user's input image content after it is converted to tokens.video_tokens integerThis field is returned if the input content includes a video. It is the length of the user's input video content after it is converted to tokens.audio_tokens integerThis field is returned if the input content includes an audio. It is the length of the user's input audio content after it is converted to tokens.output_tokens_details object (Optional)Details of the length of the output content after it is converted to tokens. This field is returned only by some models.
text_tokens integer (Optional)The length of the output text after it is converted to tokens.reasoning_tokens integer (Optional)The length of the thinking process after it is converted to tokens. This field is returned only for reasoning models.audio_tokens integer (Optional)The length of the output audio after it is converted to tokens. This field is returned only for audio output models.
prompt_tokens_details objectA fine-grained classification of input tokens.
cached_tokens integerThe number of tokens that hit the cache. For more information about context cache, see Context cache.cache_creation objectInformation about explicit cache creation.
ephemeral_5m_input_tokens integerThe length of the tokens that are used to create an explicit cache with a 5-minute validity period.
cache_creation_input_tokens integerThe length of the tokens that are used to create an explicit cache.cache_type stringIf you use explicit caching, the parameter value is ephemeral. Otherwise, this parameter does not exist.
{
  "request_id": "902fee3b-f7f0-9a8c-96a1-6b4ea25af114",
  "output": {
    "text": null,
    "finish_reason": null,
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": "我是阿里云开发的一款超大规模语言模型,我叫千问。"
        }
      }
    ]
  },
  "usage": {
    "input_tokens": 22,
    "output_tokens": 17,
    "total_tokens": 39
  }
}

Error codes

If the model call fails and an error message is returned, see Error codes to resolve the issue.