Skip to main content

DashScope API Reference

Call Qwen models through the DashScope API, and view input and output parameter descriptions and calling examples.

  • Singapore
  • United States (Virginia)
  • China (Beijing)
  • Hong Kong (China)
  • Germany (Frankfurt)
  • Japan (Tokyo)
HTTP request URL:
  • Text-only models (such as qwen-plus): POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation
  • Multimodal models (such as qwen3.7-plus or qwen3-vl-plus): POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
Region configuration for SDK calls:
  • Python code
  • Java code
  • dashscope CLI
import os
import dashscope

# The following is the configuration for the China (Beijing) region. Replace {WorkspaceId} with your actual workspace ID when making a call. The region value varies by region.
client = dashscope.Client(
    # If the environment variable is not configured, replace it with your Alibaba Cloud Model Studio API key: api_key="sk-xxx"
    # The API keys are different for different regions. To obtain an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)
When calling, replace {WorkspaceId} with your actual Workspace ID. You must have already obtained and configured an API Key and set the API Key as an environment variable. If you call through the DashScope SDK, you need to install the DashScope SDK.
Alibaba Cloud Model Studio has launched workspace-specific domains for the China (Beijing), Singapore, and Hong Kong (China) regions, which deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
  • China (Beijing) region: migrate from https://dashscope.aliyuncs.com to https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
  • Singapore region: migrate from https://dashscope-intl.aliyuncs.com to https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
  • Hong Kong (China) region: migrate from https://cn-hongkong.dashscope.aliyuncs.com to https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com
{WorkspaceId} is your Workspace ID, which you can view on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domains remain fully functional.

Request body

modelstring (Required)The model name.Supported models: Qwen large language models (commercial and open-source versions), Qwen-VL, Qwen-Coder, math models, DeepSeek, Kimi, GLM, and MiniMax.For specific model names and billing, see Select Model.messagesarray (Required)The context passed to the model, arranged in conversation order.
When calling via HTTP, place messages inside the input object.
System Messageobject (Optional)The system message, used to define the model's role, tone, task objectives, or constraints. It is generally placed first in the messages array.
Setting a System Message is not recommended for QwQ models, and it does not take effect for QVQ models.
contentstring (Required)The message content.rolestring (Required)The role of the system message, fixed as system.
User Messageobject (Required)The user message, used to pass questions, instructions, or context to the model.
contentstring or array (Required)The message content. If the input contains only text, it is of the string type; if the input contains multimodal data such as images, or explicit cache is enabled, it is of the array type.
textstring (Required)The input text.imagestring (optional)The image file used for image understanding. Images can be passed in 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 value: {"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 not specified:
  • high: processes at the original image resolution, with an upper limit of 16777216 pixels.
  • low: pixel upper limit of 2621440.
  • auto: same as low.
When max_pixels is explicitly specified, that value is used as the pixel upper limit, taking precedence over detail. The maximum value is 16777216. In Chat Completions, max_pixels is at the same level as image_url; in DashScope, it is at the same level as image.For high-resolution images, using high typically results in higher input token usage than low.In Chat Completions, detail can be passed inside image_url or at the same level as image_url; in 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 passed in when using Qwen-VL models or QVQ models.
  • If an image list is passed in, the type is array;
  • If a video file is passed in, the type is string.
For passing in local files, see Local file.Example value:
  • Image list: {"video":["https://xx1.jpg",...,"https://xxn.jpg"]}
  • Video file: {"video":"https://xxx.mp4"}
fpsfloat (optional)Number of frames extracted per second. The value range is [0.1, 10], and the default value is 2.0.
fps has two functions:
  • When a video file is input, it controls the frame extraction frequency: one frame is extracted every 1/fps seconds.
    Applicable to Qwen-VL models and QVQ models.
  • Informs the model of the time interval between adjacent frames, helping it better understand the temporal dynamics of the video. It also applies when a video file or an image list is input. This feature supports both video file and image list input, and is suitable for scenarios such as event time localization or segmented content summarization.
    Supported by Qwen3.7, Qwen3.6, Qwen3.5, Qwen3-VL, Qwen2.5-VL, and QVQ models.
A larger fps is suitable for high-speed motion scenarios (such as sports events and action movies), while a smaller fps is suitable for long videos or relatively static content.
  • Image list input: {"video":["https://xx1.jpg",...,"https://xxn.jpg"],"fps":2}
  • Video file input: {"video": "https://xx1.mp4","fps":2}
max_framesinteger (optional)The upper limit on the number of frames extracted from a video. When the number of frames calculated by fps exceeds max_frames, the system will automatically adjust to: uniformly sample frames within max_frames, ensuring the total number of frames does not exceed the limit.
  • qwen3.7 series, qwen3.6 series, and qwen3.5 series: both the maximum and default values are 8000.
  • qwen3-vl-plus series: both the maximum and default values are 2000.
{"type": "video_url","video_url": {"url":"https://xxxx.mp4"},"max_frame": 2000}
When calling with the OpenAI-compatible API, the custom max_frames parameter is not supported, and the API automatically uses the default value of each model.
min_pixelsinteger (Optional)Sets the minimum pixel threshold for input images or video frames. When the pixels of an input image or video frame are smaller than min_pixels, it will be scaled up until the total pixels exceed min_pixels.
  • Input images:
    • 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: the default value is 65536, and the minimum value is 4096.
    • kimi-k2.5, kimi-k2.6, kimi-k2.7-code: the minimum value is 3136.
    • Qwen2.5-VL open-source series and QVQ series models: the default value is 50176, and the minimum value is 3136
  • Input image: {"type": "image_url","image_url": {"url":"https://xxxx.jpg"},"min_pixels": 65536}
  • When inputting a video file: {"type": "video_url","video_url": {"url":"https://xxxx.mp4"},"min_pixels": 65536}
  • When inputting an image list: {"type": "video","video": ["https://xx1.jpg",...,"https://xxn.jpg"],"min_pixels": 65536}
max_pixelsinteger (Optional)Sets the maximum pixel threshold for input images or video frames. When the pixels of an input image or video are within the [min_pixels, max_pixels] range, the model recognizes the original image. When the input image pixels exceed max_pixels, the image is scaled down until the total pixels are below max_pixels.
  • Input images:
    • qwen4-max: the maximum value is 16777216. If not specified, images are processed based on detail; an explicitly specified max_pixels is not affected by vl_high_resolution_images.
    Other models: the value of max_pixels depends on whether the vl_high_resolution_images parameter is enabled.
    • When 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
    • When vl_high_resolution_images is True:
      • Qwen3.7、Qwen3.6、Qwen3.5, Qwen3-VL: max_pixels is invalid, and the maximum pixels of input images is fixed at 16777216
      • Qwen2.5-VL open-source series and QVQ series models: max_pixels is invalid, and the maximum pixels of input images is fixed at 12845056
  • Input video file or image list: When min_pixels and max_pixels are specified at the same time, max_pixels must not be smaller than 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: the default value is 655360, and the maximum value is 2048000.
    • qwen3-omni-flash: the default value is 655360, and the maximum value is 786432.
    • kimi-k2.5, kimi-k2.6, kimi-k2.7-code: the maximum value is 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
  • Input image: {"type": "image_url","image_url": {"url":"https://xxxx.jpg"},"max_pixels": 8388608}
  • When inputting a video file: {"type": "video_url","video_url": {"url":"https://xxxx.mp4"},"max_pixels": 655360}
  • When inputting an image list: {"type": "video","video": ["https://xx1.jpg",...,"https://xxn.jpg"],"max_pixels": 655360}
total_pixelsinteger (Optional)The total pixel budget after video frame extraction.
  • 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。
  • When inputting a video file: {"type": "video_url","video_url": {"url":"https://xxxx.mp4"},"total_pixels": 134217728}
  • When inputting an image list: {"type": "video","video": ["https://xx1.jpg",...,"https://xxn.jpg"],"total_pixels": 134217728}
cache_controlobject (Optional)Only supported by models that support explicit cache, used to enable explicit cache.
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. Required unless the assistant message includes the tool_calls parameter.rolestring (Required)Fixed to assistant.partialboolean(Optional)Whether to enable partial mode. Related documentation and supported models: Partial mode.tool_calls array(Optional)The tool and input parameter information returned after Function Calling is initiated, containing one or more objects. Obtained from the tool_calls field of the previous model response.
id stringThe ID of the tool call.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. You can obtain it via response.output.choices[0].message.tool_calls[$index]["id"]. It is used to identify the tool corresponding to the Tool Message.
temperaturefloat(Optional)qwen4-max: 1.0 in thinking mode, and 0.7 in non-thinking mode.The sampling temperature, which controls the diversity of the text generated by the model.A higher temperature produces more diverse text, while a lower temperature produces more deterministic text.Value range: [0, 2)
When calling via HTTP, place temperature in the parameters object.
It is not recommended to change the default temperature value of QVQ models.
top_pfloat(Optional)qwen4-max: 0.95 in thinking mode, and 0.8 in non-thinking mode.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 value makes the generated text more deterministic.Value range: (0,1.0].
In the Java SDK, it is topP. When calling via HTTP, put top_p in the parameters object.
We do not recommend changing the default top_p value of QVQ models.
top_kinteger (optional)The size of the candidate set sampled during generation. For example, when the value is 50, only the 50 highest-scoring tokens in a single generation form the candidate set for random sampling. A larger value leads to higher randomness in generation; a smaller value leads to higher determinism. A value of None or a top_k greater than 100 indicates that the top_k strategy is disabled, and only the top_p strategy takes effect.The value must be greater than or equal to 0.
QVQ series: 10;QwQ series: 40;All other models: 20;GLM series (Alibaba Cloud direct): 20;The 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 QVQ models.
enable_thinking boolean (optional)Whether to enable thinking mode when using hybrid thinking models. This applies to Qwen4, Qwen3.8, Qwen3.7, Qwen3.6, Qwen3.5, Qwen3, and Qwen3-VL models, as well as the DeepSeek-V4 series, Kimi-K2.6/K2.5 series, and GLM series. The DeepSeek-V4 series enables thinking by default, and you can adjust the reasoning effort via the reasoning_effort parameter.Optional 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 restoring historical thinking.preserve_thinking boolean (optional) The default value is false (for qwen4-max and qwen3.8-max, the default value istrue)Whether to append the reasoning_content of assistant messages in the conversation history to the model input. This applies to scenarios where the model needs to reference the historical thinking process.Currently supported: qwen4-max, qwen3.8-max (enabled by default), qwen3.8-max-0902 (enabled by default), qwen3.8-flash, 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 (Alibaba Cloud Model Studio deployment), kimi-k2.7-code (Alibaba Cloud Model Studio deployment, 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, preserve_thinking is true by default, and you must pass back all reasoning_content from the conversation history in full. Appending reasoning_content to the content field for passback is not supported.
  • If the historical messages do not contain reasoning_content, enabling this parameter will not cause an error and is fully compatible.
  • After it is enabled, reasoning_content in the historical conversation will be counted toward the input tokens and billed.
When calling via HTTP, put preserve_thinking into the parameters object. Not supported by the Java SDK 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, and Kimi series models, among which kimi-k3 and kimi-k3.1-pro do not support this parameter. Related document: Limit thinking length. Default value: 131072 (qwen4-max).Other models: the default value is the maximum chain-of-thought length of the model. See: Select Model
In the Java SDK, this parameter is thinkingBudget. When calling via HTTP, put thinking_budget into the parameters object.
Other models: the default value is the maximum chain-of-thought length of the model.
reasoning_effort string (optional)qwen4-maxDefault value: reasoning_effort=high.
reasoning_effortActual level
minimal, lowlow
medium, highhigh
xhigh, maxxhigh
noneDisable thinking
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 based on 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 reasoning effort of the model. Different models support different available 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: medium reasoning
  • low: light reasoning
enable_thinking defaults to true. It can be set to false to disable thinking, but we recommend keeping it enabled, as disabling it significantly affects model output quality.DeepSeek-V4, GLM series, and kimi/kimi-k3 (default value is high)Optional 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, deepseek-v4-pro (except deepseek-v4-flash-0731), and kimi/kimi-k3glm-5.3, ZHIPU/GLM-5.3, and kimi-k3 (directly provided by Alibaba Cloud) models: the default value ismaxOptional values:
  • max (default): deep reasoning
  • high: enhanced reasoning
  • low: light reasoning
These models always have thinking enabled. enable_thinking only supports true, and passing false will cause the API request to fail.deepseek-v4-flash-0731 and deepseek-v4-pro-0813 models: the default value ishighOptional values:
  • max: maximum-effort reasoning
  • high (default): high-effort reasoning
  • low: low-effort reasoning
For compatibility, medium is mapped to high, and xhigh is mapped to high.qwen3.8 series models: the default value isxhighOptional values:
  • xhigh (default): high-effort reasoning
  • medium: medium-effort reasoning
  • low: low-effort reasoning
max is mapped to xhigh, high is mapped to xhigh, minimal is mapped to low, and none is mapped to enable_thinking=False.
Setting a value other than the above optional values and mapped values will cause an error.
Important: The qwen3.8 series does not support setting reasoning_effort and thinking_budget at the same time; setting both simultaneously will cause an error. However, the two support mutual conversion:
  • When thinking_budget is not set, the reasoning_effort level is automatically mapped to thinking_budget: low corresponds to 4096, medium corresponds to 16384, and xhigh corresponds to 262144.
  • When reasoning_effort is not set, thinking_budget is automatically mapped 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 the 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 falseOnly affects the streaming output behavior of complex tool parameters, and takes effect only in streaming calls. Regular tool parameters (all parameters are of type string) can be streamed as long as streaming is enabled; tool_stream has no effect on them. Complex tools refer to tools whose definitions contain parameters of type array or object. Currently, only the Qwen and GLM series support this.Qwen series support list:
  • qwen-max series: text modality of qwen4-max, the qwen3.8-max series, and the qwen3.7-max series
  • qwen-plus series: text modality of the qwen3.7-plus series and the qwen3.6-plus series, as well as the full modality of the qwen3.5-plus series
  • qwen-flash series: the qwen3.8-flash series, qwen3.7-flash series, and qwen3.6-flash series, as well as the full modality of qwen3.5-flash
Qwen series usage reference:
  • tool_stream=false: complex tool parameters are output all at once, which is the default behavior and is more accurate for complex formats.
  • tool_stream=true: complex tool parameters are streamed, and complex formats have no timeout risk.
Complex tools refer to tools whose definitions contain parameters of type array or object.
GLM series support list: glm-5, glm-5.1.GLM series usage reference:
  • tool_stream=false: tool parameters are output all at once, which is the default behavior and is more accurate for complex formats.
  • tool_stream=true: tool parameters are streamed, and complex formats have no timeout risk.
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 document: Code interpreterOptional values:
  • true: Enable
  • false: Disable
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 falseControls whether the reasoning_content (thinking process) of previous turns is input 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. The reasoning_content of previous turns is ignored, and only non-reasoning content such as visible text, tool calls, and results is input as context, which reduces context length and cost.
  • false (default): Disable. The reasoning_content of previous turns is retained and provided 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 degree of repetition in consecutive sequences during model generation. Increasing repetition_penalty reduces the repetition in model generation; 1.0 means no penalty. There is no strict value range—it only needs to be greater than 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)Supports 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 content repetition in the text generated by the model.Value range: [-2.0, 2.0]. Positive values reduce repetition, and negative values increase repetition.In scenarios that require 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 are 0.0.DeepSeek series (Alibaba Cloud direct supply): deepseek-r1-distill-qwen distilled version: 1;Kimi series (Alibaba Cloud direct supply): kimi-k2.7-code, kimi-k2.6, kimi-k2.5: 0.0;Kimi series (Moonshot AI direct supply): 0.0;MiniMax series (Alibaba Cloud direct supply): 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 the number of times the text appears), reducing the probability of these Tokens appearing repeatedly, 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 is 2.0: This movie is excellent. The plot is wonderful, the acting is superb, and the music is delightful to listen to. Overall, the entire film is simply marvelous. In fact, it is truly outstanding. The storyline is captivating, the performances are exceptional, and the soundtrack is equally enchanting.Parameter value is 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 great. The plot is very good, the acting is very impressive, and the music is equally excellent.Parameter value is -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 really good, the acting is really good, and the music is really 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 through HTTP, put presence_penalty into the parameters object.
vl_high_resolution_imagesboolean (Optional) The default value is falseFor qwen4-max, even if vl_high_resolution_images=true, the explicitly passed-in max_pixels still takes effect.Whether to raise the pixel limit of the input image to the pixel value corresponding to 16384 Tokens. Related documentation: Process high-resolution images.
  • vl_high_resolution_images:true, which uses a fixed resolution strategy and ignores the max_pixels setting; when the resolution is exceeded, the total pixels of the image are scaled 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, 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)
  • 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 is scaled down to within max_pixels. The default pixel limit of each model is the default value of max_pixels.
In the Java SDK, this parameter is vlHighResolutionImages (the minimum required version is 2.20.8). When calling through HTTP, put vl_high_resolution_images into the parameters object.
vl_enable_image_hw_outputboolean (Optional) The default value is falseWhether to return the dimensions of the image after scaling. The model scales the input images; when this is 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. Supported by Qwen-VL models.
In the Java SDK, this parameter is vlEnableImageHwOutput, and the minimum Java SDK version is 2.20.8*.* When calling through HTTP, put vl_enable_image_hw_output into the parameters object.
max_tokensinteger (Optional, will 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-0813deepseek-v4-flash-0731: the maximum number of tokens for the sum of the model's answer and chain-of-thought content. When the model output exceeds this value, generation stops early and the returned finish_reason is length.
  • qwen4-max: the maximum number of tokens (thinking plus final answer). 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 sum of the model's answer and chain-of-thought content. 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 sum of the model's answer and chain-of-thought content. When the model output exceeds this value, generation stops early and the returned finish_reason is length; when thinking_budget is passed, max_tokens only limits the maximum number of tokens of the model's answer, and the token count of the chain-of-thought part is controlled separately by thinking_budget.
  • Other models: the maximum number of tokens of the model's answer (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.265536131072
In the Java SDK, this parameter is maxTokens (for Qwen VL models, it is maxLength, in the Java SDK; from version 2.18.4 onwards, it can also be set to maxTokens). When calling through HTTP, put max_tokens into the parameters object.
max_completion_tokensinteger (Optional)The maximum length of the model's output, including the chain of thought and the model's answer. When the model output 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 table in the max_tokens parameter. For other models, both the default and maximum values are the model's maximum output length.Differences from max_tokens: max_completion_tokens always limits the model's complete output (chain of thought + answer); the specific scope limited by max_tokens varies depending on the model and the thinking_budget setting, as described 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
Apart from the ZHIPU direct GLM models listed in the table above, the above models do not include other third-party direct models.
There can be a discrepancy of up to 10 tokens between the actual number of output tokens and the configured max_completion_tokens value.
The Java SDK does not support this parameter yet. When calling through HTTP, put max_completion_tokens into the parameters object.
seedinteger (Optional)The random number seed. Used to ensure that results are reproducible under the same input and parameters. If the same seed is passed with other parameters unchanged, the model will return the same result as much as possible.Value range: [0,2 31 −1].
When calling through HTTP, put seed into the parameters object.
streamboolean (Optional) The default value is falseWhether to stream the response. Parameter values:
  • false: the model returns the result all at once after generating all the content.
  • true: outputs while generating, i.e., each time part of the content is generated, a chunk is output immediately.
This parameter is only supported by the Python SDK. To implement streaming output with the Java SDK, call through the streamCall interface; to implement streaming output over HTTP, specify X-DashScope-SSE as enable in the Header.
Qwen3 commercial versions (thinking mode), Qwen3 open-source versions, QwQ, and QVQ only support streaming output.
incremental_outputboolean (Optional) The default is false (for Qwen3-Max, Qwen3-VL, Qwen3 open-source versions, QwQ, and QVQ models, the default value is true)Whether to enable incremental output in streaming output mode. We recommend that you set it to true first.Parameter value:
  • 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, that is, subsequent output content does not include the 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, it is incrementalOutput. When calling via HTTP, put incremental_output into the parameters object.
QwQ models and Qwen3 models in thinking mode only support setting it to true. Since the default value of Qwen3 commercial models is false, you need to manually set it to true in thinking mode.
Qwen3 open-source models do not support setting it to false.
response_formatobject (Optional) Default value: {"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 {"type": "json_object"} is specified, you must explicitly instruct the model to output JSON in the prompt, for example, "Please output in JSON format"; otherwise an error will occur. If {"type": "json_schema", ...} is specified, the prompt does not need to contain the JSON keyword.
In the Java SDK, it 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.
For the DashScope method, you need to manually construct the JSON Schema. For the format and examples, see Obtain output in a specified format. 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 required fields, and additionalProperties to control whether fields not defined in the schema are allowed in the output (we recommend setting it to false, that is, outputting only 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 value: text (the default value is message for Qwen3-Max, Qwen3-VL, QwQ models, and Qwen3 open-source models)The format of the returned data. We recommend that you set it to message first, which makes it easier to have multi-turn conversations.
The platform will unify the default value to message in the future.
In the Java SDK, it is resultFormat. When calling via HTTP, put result_format into the parameters object.
When the model is Qwen-VL/QVQ, 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 of 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 response will still be returned in the message format.
logprobs boolean (Optional) The default value is falseWhether to return the log probabilities of the 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) The default value is 0Specifies the number of candidate tokens with the highest probability to return at each generation step.Value range: [0,5]Takes effect only when logprobs is true.
In the Java SDK, it is topLogprobs. When calling via HTTP, put top_logprobs into the parameters object.
ninteger(Optional) The default value is 1The number of responses to generate. Value range: 1-4. For scenarios that require multiple responses (such as creative writing and advertising copy), you can set a larger n value.
Currently, only qwen4-max and Qwen3 (non-thinking mode) 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 string or token_id specified by stop appears in the text generated by the model, generation stops immediately.You can pass in sensitive words to control the model's output.
When stop is an array, you cannot pass 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.You must set the tools parameter both when initiating a Function Calling and when submitting tool execution results.
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)A description of the tool function, for the model to determine when and how to call the tool function.parametersobject (Optional) 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 passing in parameters.
When calling via HTTP, put tools into the parameters object. The qwen-vl series models are not supported yet.
tool_choicestring or object (Optional) Default value is autoThe tool selection policy. If you need to force a specific tool calling method for certain types of questions (for example, always using a specific tool or disabling all tools), you can set this parameter.
  • auto The model selects the tool policy on its own;
  • 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 calling at least one tool, set the tool_choice parameter to required, and the model will always return tool call information.
    The Qwen series models do not support required yet: in non-thinking mode, tool calling cannot be guaranteed; in thinking mode, required is currently not supported.
  • {"type": "function", "function": {"name": "the_function_to_call"}} If you want to force calling a specific tool, 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 call to a specific tool.
In the Java SDK, it is toolChoice. When calling via HTTP, put tool_choice into the parameters object.
parallel_tool_calls boolean (Optional) Default value is falseWhether to enable parallel tool calls.Optional values:
  • true: enabled
  • false: disabled.
For more information about parallel tool calls, see Parallel tool calling.
In the Java SDK, it is parallelToolCalls. When calling via HTTP, put parallel_tool_calls into the parameters object.
  • Text input
  • Streaming output
  • Image input
  • Video input
  • Tool calling
  • Asynchronous Call
  • Document understanding
  • Python
  • Java
  • PHP(HTTP)
  • Node.js(HTTP)
  • C#(HTTP)
  • Go(HTTP)
  • curl
import os
import dashscope

# The following is the configuration for the Singapore region. Replace {WorkspaceId} with your actual workspace ID when making a call. The region value varies by region.
client = dashscope.Client(
    # If the environment variable is not configured, replace it with your Alibaba Cloud Model Studio API key: api_key="sk-xxx"
    # The API keys are different for different regions. To obtain an API key, see https://www.alibabacloud.com/help/model-studio/get-api-key
    api_key=os.getenv('DASHSCOPE_API_KEY'),
    workspace="{WorkspaceId}",
    region="ap-southeast-1",
)

messages = [
    {'role': 'system', 'content': [{'text': 'You are a helpful assistant.'}]},
    {'role': 'user', 'content': [{'text': 'Who are you?'}]}
]
response = client.multimodal.chat.create(
    # This example uses qwen4-max. You can replace it with another model name as needed. For a list of models, see https://www.alibabacloud.com/help/model-studio/getting-started/models
    model="qwen4-max",
    messages=messages,
    )
print(response)

chat response object (streaming and non-streaming output formats are the same)

request_idstringThe unique identifier of this call.
The Java SDK return parameter is requestId.
codestringError code, returned when the call fails.
Python SDK 2.0 does not return the envelope fields when a call fails; instead, it throws a DashScopeError (e.code/e.status_code/e.message/e.request_id).
outputobjectThe call result information.
textstringThe reply generated by the model. When the input parameter result_format is set to text, the reply content is returned to this field.finish_reasonstringThis parameter is not empty when the input parameter result_format is set to text.There are four cases:
  • null while generation is in progress;
  • stop when generation ends due to natural completion of the model output, or when a stop condition in the input parameters is triggered;
  • length when generation ends due to excessive generation length;
  • tool_calls when a tool call occurs.
choicesarrayThe model output information. The choices parameter is returned when result_format is message.
finish_reasonstringThere are four cases:
  • null while generation is in progress;
  • stop when generation ends due to natural completion of the model output, or when a stop condition in the input parameters is triggered;
  • length when generation ends due to excessive generation length;
  • tool_calls when a tool call occurs.
messageobjectThe message object output by the model.
rolestringThe role of the output message, fixed to assistant.contentstring or arrayThe content of the output message. It is an array when using qwen-vl or qwen-audio series models, and a string in all other cases.
If Function Calling is initiated, this value is empty.
textstringThe content of the output message when using 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 (numeric unit: pixels)
  • Video input: returns an empty array
encrypted_content stringqwen4-max, thinking_display="summarized": The enabling parameter must be passed in every turn. The client can only return the ciphertext as-is; it cannot read, truncate, re-encode, modify, or concatenate ciphertext across turns. The summary cannot replace the historical chain-of-thought. Chain-of-thought summary and encryption.reasoning_content stringThe model's deep thinking content.tool_callsarrayIf the model needs to call tools, the tool_calls parameter is generated.
functionobjectThe name of the tool to call, and the input parameters.
namestringThe name of the tool to callargumentsstringThe parameters to be input into the tool, as a JSON string.
Due to the inherent randomness of large model responses, the output JSON string may not always satisfy your function. It is recommended that you validate the parameters before passing them to 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, fixed as function.
logprobsobjectThe probability information of the current choices object.
content arrayAn array of tokens with log probability information.
token stringThe current Token.bytes arrayThe list of raw UTF‑8 bytes of the current Token, used to accurately reconstruct the output content, which is helpful when processing emojis and Chinese characters.logprob floatThe log probability of the current Token. A returned value of null 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 top_logprobs input parameter.
token stringThe current Token.bytes arrayThe list of raw UTF‑8 bytes of the current Token, used to accurately reconstruct the output content, which is helpful when processing emojis and Chinese characters.logprob floatThe log probability of the current Token. A returned value of null indicates an extremely low probability.
usagemapThe token information used in this chat request.
input_tokens integerThe length of the user input content after being converted into tokens. Additional notesoutput_tokens integerThe length of the model output content after being converted into tokens.input_tokens_details object (optional)Details of the length of the input content after being converted into tokens.
text_tokens integer (optional)The length of the input text after being converted into tokens.image_tokens integer (optional)The length of the input images after being converted into tokens.video_tokens integer (optional)The length of the input video files or image list after being converted into tokens.
total_tokens integerThis field is returned when the input is plain text. It is the sum of input_tokens and output_tokens.image_tokens integerThis field is returned when the input content contains image. It is the length of the image content input by the user after being converted into tokens.video_tokens integerThis field is returned when the input content contains video. It is the length of the video content input by the user after being converted into tokens.audio_tokens integerThis field is returned when the input content contains audio. It is the length of the audio content input by the user after being converted into tokens.output_tokens_details object (optional)Details of the length of the output content after being converted into tokens. Some models return this field.
text_tokens integer (optional)The length of the output text after conversion to tokens.reasoning_tokens integer (optional)The length of the thinking process after conversion to tokens. Only reasoning models return this field.audio_tokens integer (optional)The length of the output audio after conversion to tokens. Only models with audio output return this field.
prompt_tokens_details objectThe 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 token length used to create an explicit cache with a 5-minute validity period.
cache_creation_input_tokens integerThe token length used to create an explicit cache.cache_type stringWhen explicit cache is used, 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": "I am a large-scale language model developed by Alibaba Cloud, and my name is Qwen."
        }
      }
    ]
  },
  "usage": {
    "input_tokens": 22,
    "output_tokens": 17,
    "total_tokens": 39
  }
}

Error codes

If a model call fails and returns an error message, see Error codes for troubleshooting.