ImportantAlibaba 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 model name.
Supported models: Qwen Large Language Model (commercial and open source versions), Qwen-VL, Qwen-Coder, Qwen-Omni, Qwen-Math, DeepSeek(supplied by Alibaba Cloud, SiliconFlow, and Vanchin), Kimi(supplied by Alibaba Cloud and Moonshot AI), GLM(supplied by Alibaba Cloud), and MiniMax(supplied by Alibaba Cloud and MiniMax).
Third-party models are available only in the China (Beijing) regions on the Alibaba Cloud China Website (www.aliyun.com). Before you can call these models, you must first activate the corresponding service in the Model Studio console. For example, to use the SiliconFlow DeepSeek model, search for deepseek, find the SiliconFlow DeepSeek model card, click Activate Now, and then confirm the authorization.
Qwen-Audio does not support the OpenAI compatible protocol. It only supports the DashScope protocol.
The context passed to the large language model, arranged in conversational order.
Message type
System Messageobject(Optional)
A system message that defines the role, tone, task, or constraints for the large language model. It is usually the first element in the messages array.
Do not set a system message for QwQ models. System messages have no effect on QVQ models.
Properties
contentstring(Required)
The system instruction. It specifies the model's role, behavior, response style, and task constraints.
rolestring(Required)
The role for the system message. The value is fixed to system.
User Messageobject(Required)
The user message. It passes questions, instructions, or context to the model.
Properties
contentstring or array(Required)
The message content. The type is string if the input is text only. The type is array if the input contains multimodal data such as images, or if explicit caching is enabled.
Properties for multimodal models or when explicit caching is enabled
typestring(Required)
Valid values:
text
Set to text for text input.
image_url
Set to image_url for image input.
input_audio
Set to input_audio for audio input.
video
Set to video for video input as a list of images.
video_url
Set to video_url for video file input.
Only some Qwen-VL models support video file input. For more information, see Video understanding (Qwen-VL). QVQ and Qwen-Omni models support direct video file input.
textstring
The input text. This parameter is required when type is text.
image_urlobject
The input image information. This parameter is required when type is image_url.
It informs the model of the time interval between adjacent frames to help it better understand the video's progression over time. This applies to both video file and image list inputs. This feature 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, Qwen3.8-Omni-Flash, Qwen3.5-Omni, and QVQ models.
A larger fps value is suitable for high-speed motion scenarios, such as sports events or action movies. A smaller fps value is suitable for long videos or scenes with static content.
Example values
Input for an image list: {"video":["https://xx1.jpg",...,"https://xxn.jpg"],"fps":2}
Video file input: {"video": "https://xx1.mp4", "fps":2}
min_pixelsinteger(Optional)
Sets the minimum pixel threshold for input images or video frames. If an input's pixel count is less than min_pixels, it is enlarged until its total pixel count is greater than min_pixels. See the supported models and values below.
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)
Specifies the maximum pixel threshold for input images or video frames. If the pixel count of an input image or video is within the [min_pixels, max_pixels] range, the model processes the original image. If the pixel count is greater than max_pixels, the image is scaled down until its pixel count is less than or equal to max_pixels. See the supported models and values below.
Value range
Image input:
The value of max_pixels depends on whether the vl_high_resolution_images parameter is enabled.
qwen3.8-omni-flash, Qwen3.5-Omni: Default value: 1310720. Maximum value: 16777216
Qwen2.5-VL open source series, and QVQ series models: Default value: 1003520. Maximum value: 12845056
When vl_high_resolution_images is True:
qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, qwen3.8-omni-flash, Qwen3.7, Qwen3.6, Qwen3.5-Omni, Qwen3.5, Qwen3-VL: max_pixels is invalid. The maximum pixel count for input images is fixed at 16777216.
Qwen2.5-VL open source series, and QVQ series models: max_pixels is invalid. The maximum pixel count for input images is fixed at 12845056.
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)
Limits the total pixel count of all frames extracted from a video, which is calculated as (pixels per frame × total frames). If the total pixel count of the video exceeds this limit, the system scales down the video frames. The system ensures that the pixel count of a single frame remains within the [min_pixels, max_pixels] range. See the supported models and values below.
For long videos with many extracted frames, you can reduce this value to decrease token consumption and processing time, but this may result in a loss of image detail.
Value range
qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, Qwen3.7 series, Qwen3.6 series, Qwen3.5 series: Default and maximum value: 819200000. This corresponds to 800000 image tokens (1 image token per 32×32 pixels).
Qwen3-VL closed-source series: Default and maximum value: 134217728. This corresponds to 131072 image tokens (1 image token per 32×32 pixels).
qwen3.8-omni-flash, Qwen3.5-Omni: Default and minimum value: 184549376. This corresponds to 180224 image tokens (1 image token per 32×32 pixels).
Other Qwen3-VL open source models: Default and minimum value: 67108864. This corresponds to 65536 image tokens (1 image token per 32×32 pixels).
Qwen2.5-VL open source series, and QVQ series models: Default and minimum value: 51380224. This corresponds to 65536 image tokens (1 image token per 28×28 pixels).
Example values
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}
cache_controlobject(Optional)
Enables explicit caching. For more information, see Explicit caching.
Properties
typestring(Required)
Only ephemeral is supported.
rolestring(Required)
The role for the user message. The value is fixed to user.
Assistant Message object(Optional)
The model's reply. It is typically passed back to the model as context in a multi-turn conversation.
Properties
contentstring(Optional)
The text content of the model's reply. When tool_calls is included, content can be empty. Otherwise, content is required.
rolestring(Required)
The role for the assistant message. The value is fixed to assistant.
The information about the tool and its input parameters that the model decides to call. It contains one or more objects and is obtained from the tool_calls field of the previous model response.
Properties
idstring(Required)
The ID of the tool call.
typestring(Required)
The tool type. Currently, only function is supported.
functionobject(Required)
Tools and input parameters
Properties
namestring(Required)
The tool name.
argumentsstring(Required)
The input parameter information, as a JSON formatted string.
indexinteger(Required)
The index of this tool call in the tool_calls array.
Tool Message object(Optional)
The result of the tool call.
Properties
contentstring(Required)
The output content of the tool function. It must be a string. If the tool returns structured data, such as JSON, it must be serialized into a string.
rolestring(Required)
The value is fixed to tool.
tool_call_idstring(Required)
The ID of the tool call that this message is a response to. You can obtain it from completion.choices[0].message.tool_calls[$index].id. This ID is used to associate the tool message with the corresponding tool call.
streamboolean(Optional) Default value: false
Specifies whether to reply in streaming output mode. For more information, see Streaming output.
Valid values:
false: The model returns the complete content after generation is finished.
true: The model outputs content as it is generated. A data chunk is returned each time a part of the content is generated. You must read these chunks to assemble the complete reply.
We recommend that you set this to true to improve the user experience and reduce the risk of timeouts.
NoteFor non-streaming calls, the maximum timeout is at least 300 seconds and varies by region and model. If not completed in time, the service interrupts the request and returns the generated content instead of an error. We recommend that you use streaming calls for scenarios that require long outputs. For more information, see the timeout description in Overview of text generation models.
stream_optionsobject(Optional)
Configuration items for streaming output. This parameter takes effect only when stream is set to true.
The voice and format of the output audio. This parameter applies to Qwen-Omni models that support audio output and requires the modalities parameter to be set to ["text","audio"]. For more information, see Non-real-time (Qwen-Omni).
The format of the output audio. Only wav is supported.
temperaturefloat(Optional)
The sampling temperature, which controls the diversity of the text generated by the model.
A higher temperature results in more diverse text, while a lower temperature results in more deterministic text.
Value range: [0, 2)
MiniMax/MiniMax-M3.1-Flash and MiniMax/MiniMax-M3 always use 1.0. You cannot customize this parameter. Other values do not take effect.
Both temperature and top_p can control the diversity of the generated text. We recommend that you set only one of them. For more information, see Overview.
Default temperature values
qwen3.8-max/qwen3.8-flash (thinking mode): Visual Understanding: 0.6; Text Input: 1.0; Values below 0.6 will be automatically reset to 0.6.
Qwen3.8-Omni-Flash: 0.6 in thinking mode and 0.7 in non-thinking mode;
DeepSeek series (supplied by Alibaba Cloud): deepseek-v4.1-flash, deepseek-v4-pro: 1.0; deepseek-r1-distill-qwen distilled version: 0.6;
DeepSeek series (supplied by SiliconFlow): siliconflow/deepseek-v3.2, siliconflow/deepseek-v3.1-terminus, siliconflow/deepseek-r1-0528, siliconflow/deepseek-v3-0324: 1.0;
DeepSeek series (supplied by Vanchin): 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 (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 (supplied by Moonshot AI): 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 (supplied by Alibaba Cloud): glm-5.1, glm-5: 1.0;
GLM series (supplied by ZHIPU AI): ZHIPU/GLM-5.1, ZHIPU/GLM-5: 0.6;
MiniMax series (supplied by Alibaba Cloud): MiniMax-M2.5: 1.0;
MiniMax series (provided directly by MiniMax): MiniMax/MiniMax-M3.1-Flash, MiniMax/MiniMax-M3, MiniMax/MiniMax-M2.7, MiniMax/MiniMax-M2.5, and MiniMax/MiniMax-M2.1: 1.0.
MiMo series (supplied by Xiaomi): mimo-v2.5-pro: 1.0, range [0, 1.5]; xiaomi/mimo-v2.6-pro-ultraspeed: 1.0, not customizable. If you pass another value, 1.0 still takes effect.
Do not modify the default temperature value for 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 results in more diverse text. A lower top_p results in more deterministic text.
Value range: (0, 1.0]
MiniMax/MiniMax-M3.1-Flash and MiniMax/MiniMax-M3 always use 0.95. You cannot customize this parameter. Other values do not take effect.
Both temperature and top_p can control the diversity of the generated text. We recommend that you set only one of them. For more information, see Overview.
Default top_p values
the following models in non-thinking mode (qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b), Qwen3.7 (non-thinking mode), Qwen3.6 (non-thinking mode), Qwen3.5-Omni, 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;
Qwen3.8-Omni-Flash: 0.95 in thinking mode and 0.8 in non-thinking mode;
DeepSeek series (supplied by Alibaba Cloud): deepseek-v4-pro, deepseek-r1-distill-qwen distilled version: 0.95;
DeepSeek series (supplied by SiliconFlow): siliconflow/deepseek-v3.2, siliconflow/deepseek-v3.1-terminus, siliconflow/deepseek-r1-0528, siliconflow/deepseek-v3-0324: 1.0;
DeepSeek series (supplied by Vanchin): 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 (supplied by Alibaba Cloud): kimi-k2.7-code, kimi-k2.6, kimi-k2.5: 0.95;
Kimi series (supplied by Moonshot AI): 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 (supplied by Alibaba Cloud): 0.95;
GLM series (supplied by ZHIPU AI): ZHIPU/GLM-5.1, ZHIPU/GLM-5: 0.95;
MiniMax series (supplied by Alibaba Cloud): MiniMax-M2.5: 0.95;
MiniMax series (supplied by MiniMax): MiniMax/MiniMax-M3.1-Flash and MiniMax/MiniMax-M3: 0.95; MiniMax/MiniMax-M2.7, MiniMax/MiniMax-M2.5, and MiniMax/MiniMax-M2.1: 0.9.
MiMo series (supplied by Xiaomi): xiaomi/mimo-v2.5-pro: 0.95, range [0.01, 1.0]; xiaomi/mimo-v2.6-pro-ultraspeed: 0.95, not customizable. If you pass another value, 0.95 still takes effect.
Do not modify the default top_p value for QVQ models.
top_kinteger(Optional)
Specifies the number of candidate tokens to sample from during generation. A larger value results in more random output, while a smaller value results in more deterministic output. If set to null or a value greater than 100, the top_k strategy is disabled, and only the top_p strategy takes effect. The value must be an integer greater than or equal to 0.
Default top_k values
QVQ series: 10;
QwQ series: 40;
qwen-math series, qwen-audio-turbo series: 1;
Qwen3-Omni-Flash series: 50;
All other models: 20.
GLM series (supplied by Alibaba Cloud): 20;
The DeepSeek, Kimi, and MiniMax series do not support the top_k parameter.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"top_k":xxx}.
Do not modify the default top_k value for QVQ models.
repetition_penaltyfloat(Optional)
The repetition penalty for consecutive sequences during model generation. Increasing repetition_penalty can reduce repetition in the model's output. A value of 1.0 means no penalty. There is no strict value range, as long as it is greater than 0.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"repetition_penalty":xxx}.
Do not modify the default repetition_penalty value for QVQ models.
presence_penaltyfloat(Optional)
Controls the content repetition when the model generates text.
Value range: [-2.0, 2.0]. Positive values reduce repetition, while negative values increase it.
In scenarios that require diversity, fun, or creativity, such as creative writing or brainstorming, you can increase this value. In scenarios that emphasize consistency and term accuracy, such as technical documents or formal texts, you can decrease this value.
DeepSeek series (supplied by Alibaba Cloud): deepseek-r1-distill-qwen distilled version: 1;
Kimi series (supplied by Alibaba Cloud): kimi-k2.7-code, kimi-k2.6, kimi-k2.5: 0.0;
Kimi series (supplied by Moonshot AI): 0.0;
MiniMax series (supplied by Alibaba Cloud): MiniMax-M2.5: 0.0;
Other DeepSeek, Kimi, GLM, and MiniMax models have no default value.
How it works
If the parameter value is positive, the model applies a penalty to tokens that already exist in the text. The penalty is not related to the number of times the token appears. This reduces the likelihood of these tokens reappearing, thus reducing content repetition and increasing word diversity.
Example
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 great. The plot is fantastic, the acting is superb, and the music is also very beautiful. Overall, the entire film is just incredible. It is actually truly outstanding. The storyline is very exciting, the performances are excellent, and the soundtrack is so moving.
Parameter value 0.0: This movie is good. The plot is good, the acting is good, and the music is good. Overall, the whole movie is very good. In fact, it is really great. The plot is very good, the acting is also very excellent, and the music is equally outstanding.
Parameter value -2.0: This movie is good. The plot is good, the acting is good, and the music is good. 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.
Do not modify the default presence_penalty value for QVQ models.
{"type": "json_object"}: Outputs a standard JSON formatted string.
{"type": "json_schema", "json_schema": {...}}: Outputs a JSON string that strictly conforms to the specified JSON Schema, which gives you precise control over the output structure and field types.
For more information, see Structured output. The json_object and json_schema modes support different models. For more information, see Supported models.
If you specify {"type": "json_object"}, you must explicitly instruct the model to output JSON in the prompt, such as "Please output in JSON format". Otherwise, an error occurs. If you specify {"type": "json_schema", ...}, the prompt does not need to contain the JSON keyword.
Properties
typestring(Required)
The format of the returned content. Valid values:
text: Outputs a text reply.
json_object: Outputs a standard JSON formatted string.
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. Defines the JSON structure that the model output must follow. For more information, see Getting structured output.
When you use the parse method of the OpenAI SDK, you can pass in a Python Pydantic class or a Node.js Zod object directly. The SDK converts it to a JSON Schema automatically, so you do not need to construct one manually.
Properties
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 list the required fields, and additionalProperties to control whether fields that are not defined in the schema can be returned. We recommend that you set additionalProperties to false so that only defined fields are returned. Supported data types: string, number, integer, boolean, object, array, and enum. For more information, see Configuration guide.
strictboolean(Optional)
Specifies whether to strictly follow the structure defined by schema. We recommend that you set this parameter to true.
max_tokensinteger(Optional, to be deprecated)
This parameter will be deprecated. For new integrations, use max_completion_tokens.
The meaning of this parameter varies by model:
deepseek-v4.1-flash, deepseek-v4-pro, deepseek-v4-pro-0813, deepseek-v4-flash-0731: The maximum number of tokens for the sum of the model's answer and chain-of-thought content. If the model's output exceeds this value, generation stops early, and the returned 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. If the model's 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, and if the model's output exceeds this value, generation stops early with the returned finish_reason being length. When the thinking_budget parameter is passed, max_tokens is the maximum number of tokens for the model's answer only, and the number of tokens for the chain-of-thought part is controlled separately by thinking_budget.
Other models: The maximum number of tokens for the model's answer (excluding chain-of-thought). If the generated content exceeds this value, generation stops early, and the returned finish_reason is length.
For GLM models, the default and maximum values are listed in the following table. For other models, the default and maximum values are both the model's maximum output length.
The maximum length of the model's output, including the chain-of-thought and the model's answer. If the model's 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, the default and maximum values are both the model's maximum output length.
Difference from max_tokens: max_completion_tokens always limits the complete model output (chain-of-thought + answer). The specific scope of max_tokens varies by model and the thinking_budget setting, as described above. For thinking models, we recommend that you use max_completion_tokens.
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 models
GLM: The Alibaba Cloud-supplied and ZHIPU AI-supplied models listed in the preceding table
MiniMax: MiniMax-M2.5 and later models
DeepSeek: deepseek-v4-pro and later models
Except for the ZHIPU AI-supplied GLM models listed in the preceding table, the models above do not include other third-party direct-supply models.
There may be a difference of up to 10 tokens between the actual output token count and the specified max_completion_tokens value.
Specifies whether to increase the pixel limit for input images to the pixel count that corresponds to 16384 tokens. For more information, see Processing high-resolution images.
vl_high_resolution_images: true uses a fixed resolution strategy and ignores the max_pixels setting. If the resolution is exceeded, the total pixel count of the image is scaled down to stay within this limit.
Click to view the pixel limits for each model
When vl_high_resolution_images is True, the pixel limits vary by model:
For the qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, qwen3.8-omni-flash, Qwen3.7 series, Qwen3.6 series, Qwen3.5 series, Qwen3-VL series models, the value is 16777216. (Each Token corresponds to 32*32 pixels. The total value is calculated as 16384*32*32.)
QVQ series, other Qwen2.5-VL series models: 12845056 (1 token corresponds to 28*28 pixels, which is 16384*28*28)
vl_high_resolution_images is false, the pixel limit is determined by max_pixels. If the input image's pixel count exceeds max_pixels, the image is scaled down to within the max_pixels limit. The default pixel limit for each model is the default value of max_pixels.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"vl_high_resolution_images":xxx}.
ninteger(Optional) Default value: 1
The number of responses to generate. The value range is 1-4. This is suitable for scenarios that require multiple candidate responses, such as creative writing or ad copy.
n=0 is equivalent to n=1.
Only Qwen3 (non-thinking mode) and qwen-plus-character support values greater than 1. MiniMax/MiniMax-M3.1-Flash and MiniMax/MiniMax-M3 support only n=1. kimi/kimi-k3.1-pro and kimi/kimi-k3.1-pro-highspeed do not support this parameter.
If the tools parameter is passed, set n to 1.
Increasing n increases the output token consumption but not the input token consumption.
enable_thinkingboolean (Optional)
For kimi-k3.1-pro (deployed on Alibaba Cloud Model Studio), the default is true. You can set it to false to disable thinking, but keeping it enabled is strongly recommended because disabling it significantly degrades output quality.
When you use a mixed-thinking model, which supports both thinking and non-thinking modes, this parameter specifies whether to enable thinking mode. This applies to Qwen3.8, Qwen3.7, Qwen3.6, Qwen3.5, Qwen3, Qwen3.8-Omni-Flash, Qwen3-Omni-Flash, and Qwen3-VL models, along with the DeepSeek-V4.1-Flash, DeepSeek-V4-Pro/V4-Flash series(supplied by Alibaba Cloud), DeepSeek-V3.2/V3.2-exp/V3.1 series(supplied by Alibaba Cloud, SiliconFlow, and Vanchin), Kimi-K2.7-code (thinking model only), Kimi-K2.6/K2.5 series(supplied by Alibaba Cloud and Moonshot AI), and GLM series. The DeepSeek-V4 series enables thinking by default. You can adjust the inference intensity with the reasoning_effort parameter.
Valid values:
true: Enable
When enabled, the thinking content is returned in the reasoning_content field.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"enable_thinking": xxx}.
If you call over HTTP directly (for example, with curl) instead of using the OpenAI SDK, do not use extra_body. Simply place enable_thinking at the top level of the request body (body), alongside parameters such as model and messages, for example "enable_thinking": true.
MiniMax/MiniMax-M3.1-Flash and MiniMax/MiniMax-M3 supplied by MiniMax do not use this parameter. Use the thinking parameter instead.
Controls the thinking mode of MiniMax models supplied by MiniMax.
Valid values for thinking.type:
adaptive: Enables thinking. MiniMax/MiniMax-M3.1-Flash always uses this mode. MiniMax/MiniMax-M3 uses this mode by default.
disabled: Disables thinking. Only MiniMax/MiniMax-M3 supports this value. MiniMax/MiniMax-M3.1-Flash returns an HTTP 400 error if you specify it.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"thinking": {"type": "adaptive"}}.
reasoning_splitboolean (Optional)
Controls where MiniMax thinking content is returned:
true: Returns thinking content separately in reasoning_content. MiniMax/MiniMax-M3.1-Flash supports only this value.
false: Returns thinking content in content inside <think> tags. Only MiniMax/MiniMax-M3 supports this value.
This is not a standard OpenAI parameter. With the Python SDK, pass it in extra_body, for example extra_body={"reasoning_split": True}.
preserve_thinkingboolean (Optional) Default value: false (Default value for qwen3.8-max/qwen3.8-flash:true)
Specifies whether to append the reasoning_content from assistant messages in the conversation history to the model input. This is suitable for scenarios where the model needs to refer to the historical thinking process.
kimi-k3.1-pro and kimi-k3 (deployed on Alibaba Cloud Model Studio) retain historical reasoning_content supplied by the client by default. We recommend returning historical assistant messages and their complete reasoning_content in messages.
kimi/kimi-k3.1-pro and kimi/kimi-k3.1-pro-highspeed support this parameter, which is disabled by default.
To reference reasoning from a previous turn, include it in the historical assistant message's reasoning_content field in messages. See Pass the thinking process.
Currently supported by 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, qwen3.8-max (enabled by default), qwen3.8-max-0902 (enabled by default), qwen3.8-flash (enabled by default), qwen3.8-omni-flash (enabled by default), 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 (supplied by Moonshot AI, enabled by default), and kimi/kimi-k2.7-code (supplied by Moonshot AI, enabled by default).
Important (qwen3.8-max/qwen3.8-flash): When using qwen3.8-max/qwen3.8-flash, preserve_thinking defaults to true. You must send back all historical reasoning_content in the reasoning_content field. Do NOT concatenate reasoning_content into the content field. Doing so may degrade model performance.
For the supported qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, Qwen3.7, Qwen3.6, and Kimi models listed above, enabling this parameter when historical messages lack reasoning_content does not cause an error.
When enabled, the reasoning_content from the historical conversation is included in the input token count and is billed.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"preserve_thinking": True}.
thinking_budgetinteger (Optional)
The maximum number of tokens for the thinking process. This applies to the qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, as well as Qwen3.7, Qwen3.6, Qwen3.5, Qwen3-VL, Qwen3, GLM(supplied by Alibaba Cloud) and Kimi(supplied by Alibaba Cloud) models, except kimi-k3.1-pro and kimi-k3, which do not support this parameter. For more information, see Limit thinking length.
For these models, the default value is the model's maximum chain-of-thought length. For more information, see the model list.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"thinking_budget": xxx}.
use_multichannelboolean (optional)
Controls whether spatial information in multichannel audio is parsed. Applies to audio input for qwen3.8-omni-flash. Defaults to false, which parses all audio as mono. When true and the input has two channels (left and right) or four channels (FOA, in WYZX order), the model parses spatial audio information. Set it at the top level of the HTTP request body, or pass extra_body={"use_multichannel": True} with the OpenAI Python SDK.
reasoning_effortstring (Optional)
Controls the inference intensity of models. The valid values and default values vary by model.
kimi-k3.1-pro (deployed on Alibaba Cloud Model Studio) (default: max)
max (default): deep reasoning
high: enhanced reasoning
medium: moderate reasoning
low: light reasoning
MiniMax/MiniMax-M3.1-Flash (Default value: max)
Valid values from lowest to highest inference intensity are low, medium, high, xhigh, and max. The model always performs thinking. Setting this parameter to none returns an HTTP 400 error.
DeepSeek-V4 and GLM series (Default value: high)
Valid values:
high: High-intensity inference
max: Maximum-intensity inference
low and medium are mapped to high, and xhigh is mapped to max.
This applies to glm-5.2, glm-5.1, glm-5, deepseek-v4-pro (supplied by Alibaba Cloud).
glm-5.3、ZHIPU/GLM-5.3、ZHIPU/GLM-5.3-Flash、ZHIPU/GLM-5.3-FlashX、kimi-k3model(supplied by Alibaba Cloud): Default value:max
Valid values:
max (default): deep reasoning
high: enhanced reasoning
low: light reasoning
The glm-5.3 series models always perform thinking. enable_thinking supports only true, and passing false causes the API request to fail. kimi-k3 supports passing false to disable thinking.
OpenAI standard value mapping: max is mapped to xhigh, high is mapped to xhigh, minimal is mapped to low, and none is mapped to enable_thinking=False.
Setting values other than the above valid values and mapped values will cause an error.
For the qwen3.8-max, qwen3.8-max-0902, qwen3.8-flash, qwen3.8-2.4t-a95b, qwen3.8-27b, reasoning_effort and thinking_budget cannot be set at the same time. Setting both will cause an error. However, they support mutual conversion:
When thinking_budget is not set, the reasoning_effort levels are 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 default reasoning_effort (xhigh) are used.
Qwen3.8-Omni-Flash
qwen3.8-omni-flash has thinking enabled by default, with reasoning_effort defaulting to xhigh. In Chat Completions, reasoning_effort accepts none, minimal, low, medium, high, xhigh, and max; do not set it together with thinking_budget. For parameter placement and examples, see Qwen3.8 Omni.
Choose low, medium, or xhigh for the thinking effort. For compatibility, minimal maps to low, high and max map to xhigh, and none disables thinking.
Takes effect only when stream=true. This parameter is currently supported only by Qwen and GLM series.
Qwen series support list:
qwen-max series: text modality of the qwen3.8-max and qwen3.7-max series
qwen-plus series: text modality of the qwen3.7-plus and qwen3.6-plus series, and omni-modality of the qwen3.5-plus series
qwen-flash series: omni-modality of the qwen3.8-flash, qwen3.7-flash, qwen3.6-flash and qwen3.5-flash series
Qwen series usage reference:
tool_stream only affects complex tool parameters. For normal tool parameters, streaming output is enabled as long as stream=true. Complex tools are tools where some parameter types in the tool definition are array or object.
tool_stream=false: Complex tool parameters are output at once. This is the default behavior, and complex formats are more accurate.
tool_stream=true: Complex tool parameters are output in a stream, which avoids timeout risks for complex formats.
GLM series support list: glm-5, and glm-5.1(supplied by Alibaba Cloud).
GLM series usage reference:
tool_stream=false: Tool parameters are output at once. This is the default behavior, and complex formats are more accurate.
tool_stream=true: Tool parameters are output in a stream, which avoids timeout risks for complex formats.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"tool_stream": true}.
Specifies whether to enable the code interpreter feature. For more information, see Code interpreter.
Valid values:
true: Enable
false: Disable
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"enable_code_interpreter": xxx}.
seedinteger(Optional)
A random number seed. This parameter is used to ensure reproducible results with the same input and parameters. If you pass the same seed value in a call and other parameters remain unchanged, the model returns the same result as much as possible.
Value range: [0,2<sup>31</sup>−1].
Default seed values
All other models: 1234.
logprobsboolean (Optional) Default value: false
Specifies whether to return the log probabilities of the output tokens. Valid values:
true
Return
false
Do not return
Content generated during the thinking phase (reasoning_content) does not return log probabilities.
Supported models
Snapshot models of the qwen-plus series (excluding stable version models)
qwen3-vl-plus series models (including stable version models)
Qwen3 open source models
top_logprobsinteger (Optional) Default value: 0
Specifies the number of most likely candidate tokens to return at each generation step.
Value range: [0, 5]
This parameter takes effect only when logprobs is true.
stopstring or array(Optional)
Used to specify stop words. When a string or token_id specified in stop appears in the generated text, generation stops immediately.
MiniMax/MiniMax-M3.1-Flash does not support this parameter. Passing it does not truncate the output at the specified stop sequence. The request may still succeed and return finish_reason: "stop", but this does not mean that the specified stop sequence took effect.
You can pass sensitive words to control the model's output.
When stop is an array, you cannot input both token_id and strings as elements. For example, you cannot specify ["Hello",104307].
toolsarray(Optional)
An array that contains one or more tool objects for the model to call in Function Calling. For more information, see Function calling.
If tools is set and the model determines that a tool needs to be called, the response returns tool information in tool_calls.
Properties
typestring(Required)
The tool type. Currently, only function is supported.
functionobject(Required)
Properties
namestring(Required)
The tool name. Only letters, numbers, underscores (_), and hyphens (-) are allowed. The maximum length is 64 tokens.
descriptionstring(Required)
The tool description, which helps the model determine when and how to call the tool.
parametersobject(Optional) Default value: {}
The parameter description for the tool, which must be a valid JSON Schema. For a description of JSON Schema, see the link. If the parameters parameter is empty, the tool has no input parameters, such as a time query tool.
To improve the accuracy of tool calls, we recommend that you pass parameters.
tool_choicestring or object(Optional) Default value: auto
The tool selection strategy. To force a specific tool calling method for a certain type of problem, such as always using a specific tool or disabling all tools, you can set this parameter.
MiniMax/MiniMax-M3.1-Flash supports only auto. Other values, such as none, required, or a named function, may return an error or have no effect. Specifying a named function does not guarantee that the model calls it.
deepseek-v4.1-flash-1017 supports tool_choice set to auto, none, required, or a named function.
Valid values:
auto
The large language model chooses the tool strategy.
none
If you do not want to call a tool, you can set the tool_choice parameter to none.
required
To force at least one tool to be called, set the tool_choice parameter to required, and the model will always return tool call information.
The Qwen series models do not support required: in non-thinking mode it cannot guarantee that a tool is always called, and in thinking mode required is not supported.
If you want to force a specific tool to be called, you can 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.
Thinking mode models do not support forcing a specific tool to be called.
Specifies whether to enable parallel tool calling. For more information, see Parallel tool calling.
MiniMax/MiniMax-M3.1-Flash and kimi-k3 do not support using this parameter to control whether tool calls are parallel. Setting it to false does not guarantee sequential tool calls, and the model may still return multiple tool_calls in one turn. Process the returned tool calls as provided.
kimi/kimi-k3.1-pro and kimi/kimi-k3.1-pro-highspeed do not support this parameter.
Specifies whether to enable web search. kimi-k3.1-pro (deployed on Alibaba Cloud Model Studio) supports this parameter in Beijing, Singapore, the US (Virginia), Germany (Frankfurt), Japan (Tokyo), and China (Hong Kong). For more information, see Web search.
Valid values:
true: Enable.
If web search is not performed after enabling, you can optimize the prompt or set the forced_search parameter in search_options to enable forced search.
false: Disable.
Enabling the web search feature may increase token consumption.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"enable_search": True}.
search_optionsobject(Optional)
The strategy for web search. For more information, see Web search.
The search strategy. This parameter takes effect only when enable_search is set to true.
For qwen3.8-omni-flash, set this parameter to agent when enabling web search.
Valid values:
turbo (Default): Balances response speed and search effectiveness. This strategy is suitable for most scenarios.
max: Adopts a more comprehensive search strategy. This strategy can call multi-source search engines to obtain more detailed search results, but the response time may be longer.
agent: Can call the web search tool and the large language model multiple times to achieve multi-turn information retrieval and content integration.
This strategy is applicable only to qwen3.5-plus, qwen3.5-plus-2026-02-15, qwen3.5-flash, qwen3.5-flash-2026-02-23, qwen3.8-omni-flash, qwen3.5-omni-plus, qwen3.5-omni-plus-2026-03-15, qwen3.5-omni-flash, and qwen3.5-omni-flash-2026-03-15.
enable_search_extensionboolean(Optional) Default value: false
Specifies whether to enable vertical search. This parameter takes effect only when enable_search is set to true.
Valid values:
true: Enable.
false: Disable.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"search_options": xxx}.
include_tool_usageboolean (Optional) Defaults to false
Whether to return web search usage statistics in the response usage.
Valid values:
true: Returns the x_tools field in usage.
false: Does not return it.
x_tools is returned only when a web search is actually triggered in the request. If enable_search is not enabled, or the model determines that no web search is needed, this field is not returned even when this parameter is set to true.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"include_tool_usage": True}.
X-DashScope-DataInspectionstring (Optional)
In addition to the content moderation capabilities of the Qwen API, this parameter specifies whether to further identify non-compliant information in the input and output content. Valid values:
'{"input":"cip","output":"cip"}': Performs further detection.
If this parameter is not set, no further detection occurs.
When you call using HTTP, place it in the request header: -H "X-DashScope-DataInspection: {\"input\": \"cip\", \"output\": \"cip\"}".
When you call using the Python SDK, configure it through extra_headers: extra_headers={'X-DashScope-DataInspection': '{"input":"cip","output":"cip"}'}.
This parameter is not supported for configuration using the Node.js SDK.
skillarray(Optional)
The skill parameters, which are used to enable specific generation skills, such as PPT generation. This parameter is supported only by the qwen-doc-turbo model. For more information about its usage, see Generate PPT.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"skill": [...]}.
When you use skill, stream must be set to true.
Properties
typestring(Required)
The skill type. Currently, only the following skill type is supported:
ppt: PPT generation.
modestring (Optional)
The PPT generation mode. Valid values:
general (Default): Template mode. This mode must be used with template_id to generate a PPT in HTML format.
creative: Creative mode. No template is required. This mode generates a graphic PPT, where each page is an image.
template_idstring(Optional)
The PPT template ID. This parameter is used when mode is set to general or when mode is not set. Valid values:
Controls whether the reasoning_content (thinking process) from previous turns in a multi-turn conversation is used as context input for the model. This parameter is supported only by the GLM series models glm-5.3, glm-5.2, glm-5.1, and glm-5. The default value is true for glm-5.3 and false for the other models.
This parameter is not a standard OpenAI parameter. When you call using the Python SDK, place it in the extra_body object. Configuration: extra_body={"skill": [...]}.
true: Ignores the reasoning_content from previous turns and uses only visible text, tool calls, results, and other non-inference content as context input. This can reduce the context length and cost.
false (Default): Retains the reasoning_content from previous turns and provides it to the model along with the context. If you want to enable Preserved Thinking, you must pass the historical reasoning_content completely, unmodified, and in the original order within messages. Missing, trimming, rewriting, or reordering degrades performance or causes it to fail.
Text input
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
# Model list: https://help.aliyun.com/en/model-studio/getting-started/models
model="qwen3.8-max",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"},
]
)
print(completion.model_dump_json())
// This code uses OpenAI SDK version 2.6.0
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.chat.completions.ChatCompletion;
import com.openai.models.chat.completions.ChatCompletionCreateParams;
public class Main {
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.baseUrl("https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1")
.build();
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
.addUserMessage("Who are you?")
.model("qwen3.8-max")
.build();
try {
ChatCompletion chatCompletion = client.chat().completions().create(params);
System.out.println(chatCompletion);
} catch (Exception e) {
System.err.println("Error occurred: " + e.getMessage());
e.printStackTrace();
}
}
}
import OpenAI from "openai";
const openai = new OpenAI(
{
// If the environment variable is not configured, replace the following line with your Model Studio API key: apiKey: "sk-xxx",
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
}
);
async function main() {
const completion = await openai.chat.completions.create({
model: "qwen3.8-max", // This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Who are you?" }
],
});
console.log(JSON.stringify(completion))
}
main();
using System.Net.Http.Headers;
using System.Text;
class Program
{
private static readonly HttpClient httpClient = new HttpClient();
static async Task Main(string[] args)
{
// If the environment variable is not configured, replace the following line with your Model Studio API key: string? apiKey = "sk-xxx";
string? apiKey = Environment.GetEnvironmentVariable("DASHSCOPE_API_KEY");
if (string.IsNullOrEmpty(apiKey))
{
Console.WriteLine("API Key not set. Make sure the 'DASHSCOPE_API_KEY' environment variable is set.");
return;
}
// Set the request URL and content
string url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions";
// This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
string jsonContent = @"{
""model"": ""qwen-plus"",
""messages"": [
{
""role"": ""system"",
""content"": ""You are a helpful assistant.""
},
{
""role"": ""user"",
""content"": ""Who are you?""
}
]
}";
// Send the request and get the response
string result = await SendPostRequestAsync(url, jsonContent, apiKey);
// Print the result
Console.WriteLine(result);
}
private static async Task<string> SendPostRequestAsync(string url, string jsonContent, string apiKey)
{
using (var content = new StringContent(jsonContent, Encoding.UTF8, "application/json"))
{
// Set request headers
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// Send the request and get the response
HttpResponseMessage response = await httpClient.PostAsync(url, content);
// Process the response
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadAsStringAsync();
}
else
{
return $"Request failed: {response.StatusCode}";
}
}
}
}
<?php
// Set the request URL
$url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions';
// If the environment variable is not configured, replace the following line with your Model Studio API key: $apiKey = "sk-xxx";
$apiKey = getenv('DASHSCOPE_API_KEY');
// Set request headers
$headers = [
'Authorization: Bearer '.$apiKey,
'Content-Type: application/json'
];
// Set the request body
$data = [
// This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
"model" => "qwen-plus",
"messages" => [
[
"role" => "system",
"content" => "You are a helpful assistant."
],
[
"role" => "user",
"content" => "Who are you?"
]
]
];
// Initialize a cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Execute the cURL session
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
// Close the cURL resource
curl_close($ch);
// Print the response
echo $response;
?>
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Who are you?"
}
]
}'
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen3.8-max", # This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages=[{'role': 'system', 'content': 'You are a helpful assistant.'},
{'role': 'user', 'content': 'Who are you?'}],
stream=True,
stream_options={"include_usage": True}
)
for chunk in completion:
print(chunk.model_dump_json())
import OpenAI from "openai";
const openai = new OpenAI(
{
// If the environment variable is not configured, replace the following line with your Model Studio API key: apiKey: "sk-xxx",
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
}
);
async function main() {
const completion = await openai.chat.completions.create({
model: "qwen3.8-max", // This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages: [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"}
],
stream: true,
stream_options: {include_usage: true}
});
for await (const chunk of completion) {
console.log(JSON.stringify(chunk));
}
}
main();
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen3-vl-plus", # This example uses qwen3-vl-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages=[{"role": "user","content": [
{"type": "image_url",
"image_url": {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"}},
{"type": "text", "text": "What is this?"},
]}]
)
print(completion.model_dump_json())
import OpenAI from "openai";
const openai = new OpenAI(
{
// If the environment variable is not configured, replace the following line with your Model Studio API key: apiKey: "sk-xxx",
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
}
);
async function main() {
const response = await openai.chat.completions.create({
model: "qwen3-vl-plus", // This example uses qwen3-vl-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages: [{role: "user",content: [
{ type: "image_url",image_url: {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"}},
{ type: "text", text: "What is this?" },
]}]
});
console.log(JSON.stringify(response));
}
main();
The following example shows how to use a list of images as video input. For information about other methods, such as using video files, see Visual understanding.
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
# This example uses qwen3-vl-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
model="qwen3-vl-plus",
messages=[{
"role": "user",
"content": [
{
"type": "video",
"video": [
"https://img.alicdn.com/imgextra/i3/O1CN01K3SgGo1eqmlUgeE9b_!!6000000003923-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i4/O1CN01BjZvwg1Y23CF5qIRB_!!6000000003000-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i4/O1CN01Ib0clU27vTgBdbVLQ_!!6000000007859-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i1/O1CN01aygPLW1s3EXCdSN4X_!!6000000005710-0-tps-3840-2160.jpg"]
},
{
"type": "text",
"text": "Describe the specific process in this video"
}]}]
)
print(completion.model_dump_json())
// Make sure you have specified "type": "module" in package.json
import OpenAI from "openai";
const openai = new OpenAI({
// If the environment variable is not configured, replace the following line with your Model Studio API key: apiKey: "sk-xxx",
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
});
async function main() {
const response = await openai.chat.completions.create({
// This example uses qwen3-vl-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
model: "qwen3-vl-plus",
messages: [{
role: "user",
content: [
{
type: "video",
video: [
"https://img.alicdn.com/imgextra/i3/O1CN01K3SgGo1eqmlUgeE9b_!!6000000003923-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i4/O1CN01BjZvwg1Y23CF5qIRB_!!6000000003000-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i4/O1CN01Ib0clU27vTgBdbVLQ_!!6000000007859-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i1/O1CN01aygPLW1s3EXCdSN4X_!!6000000005710-0-tps-3840-2160.jpg"
]
},
{
type: "text",
text: "Describe the specific process in this video"
}
]}]
});
console.log(JSON.stringify(response));
}
main();
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "qwen3-vl-plus",
"messages": [
{
"role": "user",
"content": [
{
"type": "video",
"video": [
"https://img.alicdn.com/imgextra/i3/O1CN01K3SgGo1eqmlUgeE9b_!!6000000003923-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i4/O1CN01BjZvwg1Y23CF5qIRB_!!6000000003000-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i4/O1CN01Ib0clU27vTgBdbVLQ_!!6000000007859-0-tps-3840-2160.jpg",
"https://img.alicdn.com/imgextra/i1/O1CN01aygPLW1s3EXCdSN4X_!!6000000005710-0-tps-3840-2160.jpg"
]
},
{
"type": "text",
"text": "Describe the specific process in this video"
}
]
}
]
}'
A large language model generates responses based on its training data, which has a knowledge cutoff. The model cannot perceive the actual current date on its own. When you ask for the current date, the model returns an outdated date from before its training cutoff. This is not a parameter misconfiguration.
Ways to obtain the accurate current time:
Function calling: Define a get_current_time tool so that the model obtains the real time through a function call. See the following tool calling example.
System prompt injection: Inject the current date into the system message. You must pass the date dynamically on every call.
Web search: enable_search retrieves real-time information but cannot directly obtain the current time.
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1", # Enter the base_url of the DashScope SDK
)
tools = [
# Tool 1: Get the current time
{
"type": "function",
"function": {
"name": "get_current_time",
"description": "Useful when you want to know the current time.",
"parameters": {} # Because getting the current time requires no input parameters, parameters is an empty dictionary
}
},
# Tool 2: Get the weather for a specified city
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Useful when you want to query the weather of a specified city.",
"parameters": {
"type": "object",
"properties": {
# A location must be provided to query the weather, so the parameter is set to location
"location": {
"type": "string",
"description": "A city or district, such as Beijing, Hangzhou, or Yuhang District."
}
},
"required": ["location"]
}
}
}
]
messages = [{"role": "user", "content": "What's the weather like in Hangzhou?"}]
completion = client.chat.completions.create(
model="qwen3.8-max", # This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages=messages,
tools=tools
)
print(completion.model_dump_json())
import OpenAI from "openai";
const openai = new OpenAI(
{
// If the environment variable is not configured, replace the following line with your Model Studio API key: apiKey: "sk-xxx",
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
}
);
const messages = [{"role": "user", "content": "What's the weather like in Hangzhou?"}];
const tools = [
// Tool 1: Get the current time
{
"type": "function",
"function": {
"name": "get_current_time",
"description": "Useful when you want to know the current time.",
// Because getting the current time requires no input parameters, parameters is empty
"parameters": {}
}
},
// Tool 2: Get the weather for a specified city
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Useful when you want to query the weather of a specified city.",
"parameters": {
"type": "object",
"properties": {
// A location must be provided to query the weather, so the parameter is set to location
"location": {
"type": "string",
"description": "A city or district, such as Beijing, Hangzhou, or Yuhang District."
}
},
"required": ["location"]
}
}
}
];
async function main() {
const response = await openai.chat.completions.create({
model: "qwen3.8-max", // This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages: messages,
tools: tools,
});
console.log(JSON.stringify(response));
}
main();
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the weather like in Hangzhou?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_time",
"description": "Useful when you want to know the current time.",
"parameters": {}
}
},
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Useful when you want to query the weather of a specified city.",
"parameters": {
"type": "object",
"properties": {
"location":{
"type": "string",
"description": "A city or district, such as Beijing, Hangzhou, or Yuhang District."
}
},
"required": ["location"]
}
}
}
]
}'
Web search
import os
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen3.8-max", # This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages=[
{'role': 'system', 'content': 'You are a helpful assistant.'},
{'role': 'user', 'content': 'How many gold medals did the Chinese team win at the Paris Olympics?'}],
extra_body={
"enable_search": True
}
)
print(completion.model_dump_json())
import OpenAI from "openai";
const openai = new OpenAI(
{
// If the environment variable is not configured, replace the following line with your Model Studio API key: apiKey: "sk-xxx",
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
}
);
async function main() {
const completion = await openai.chat.completions.create({
model: "qwen3.8-max", // This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "How many gold medals did the Chinese team win at the Paris Olympics?" }
],
enable_search:true
});
console.log(JSON.stringify(completion))
}
main();
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-max",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How many gold medals did the Chinese team win at the Paris Olympics?"
}
],
"enable_search": true
}'
Asynchronous invocation
import os
import asyncio
from openai import AsyncOpenAI
import platform
client = AsyncOpenAI(
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
async def main():
response = await client.chat.completions.create(
messages=[{"role": "user", "content": "Who are you?"}],
model="qwen3.8-max", # This example uses qwen-plus. You can replace it with another model name as needed. Model list: https://help.aliyun.com/en/model-studio/getting-started/models
)
print(response.model_dump_json())
if platform.system() == "Windows":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
Document understanding
Currently, only the qwen-long model supports document analysis. For more information about its usage, see Long context (Qwen-Long).
import os
from pathlib import Path
from openai import OpenAI
client = OpenAI(
# If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
file_object = client.files.create(file=Path("Model_Studio_Phone_Product_Introduction.docx"), purpose="file-extract")
completion = client.chat.completions.create(
model="qwen-long", # Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages=[
{'role': 'system', 'content': f'fileid://{file_object.id}'},
{'role': 'user', 'content': 'What is this article about?'}
]
)
print(completion.model_dump_json())
// We recommend using OpenAI SDK version >= 0.32.0
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.chat.completions.ChatCompletion;
import com.openai.models.chat.completions.ChatCompletionCreateParams;
import com.openai.models.files.FileCreateParams;
import com.openai.models.files.FileObject;
import com.openai.models.files.FilePurpose;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Main {
public static void main(String[] args) {
// Create a client using the API key from the environment variable
OpenAIClient client = OpenAIOkHttpClient.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.baseUrl("https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1")
.build();
// Set the file path
Path filePath = Paths.get("Model_Studio_Phone_Product_Introduction.docx");
// Create file upload parameters
FileCreateParams fileParams = FileCreateParams.builder()
.file(filePath)
.purpose(FilePurpose.of("file-extract"))
.build();
// Upload the file
FileObject fileObject = client.files().create(fileParams);
String fileId = fileObject.id();
// Create a chat request
ChatCompletionCreateParams chatParams = ChatCompletionCreateParams.builder()
.addSystemMessage("fileid://" + fileId)
.addUserMessage("What is this article about?")
.model("qwen-long")
.build();
// Send the request and get the response
ChatCompletion chatCompletion = client.chat().completions().create(chatParams);
// Print the response
System.out.println(chatCompletion);
}
}
import fs from "fs";
import OpenAI from "openai";
const openai = new OpenAI(
{
// If the environment variable is not configured, replace the following line with your Model Studio API key: apiKey: "sk-xxx",
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
}
);
async function getFileID() {
const fileObject = await openai.files.create({
file: fs.createReadStream("Model_Studio_Phone_Product_Introduction.docx"),
purpose: "file-extract"
});
return fileObject.id;
}
async function main() {
const fileID = await getFileID();
const completion = await openai.chat.completions.create({
model: "qwen-long", // Model list: https://help.aliyun.com/en/model-studio/getting-started/models
messages: [
{ role: "system", content: `fileid://${fileID}`},
{ role: "user", content: "What is this article about?" }
],
});
console.log(JSON.stringify(completion))
}
main();
stop: The model stopped generating because it triggered the stop parameter in the input or stopped naturally.
length: The model stopped generating because the generation length is too long.
tool_calls: The model stopped generating because a tool needs to be called.
indexinteger
The index of this object in the choices array.
logprobsobject
The token probability information of the model's output.
Properties
contentarray
An array that contains each token and its log probability.
Properties
tokenstring
The text of the current token.
bytesarray
A list of the raw UTF-8 bytes of the current token. This is used to accurately restore the output content, such as emojis or Chinese characters.
logprobfloat
The log probability of the current token. A return value of null indicates an extremely low probability.
top_logprobsarray
The most likely candidate tokens at the current token position. The number of tokens is consistent with the top_logprobs request parameter. Each element contains:
Properties
tokenstring
The text of the candidate token.
bytesarray
A list of the raw UTF-8 bytes of the current token. This is used to accurately restore the output content, such as emojis or Chinese characters.
logprobfloat
The log probability of this candidate token. A null value indicates an extremely low probability.
messageobject
The message that is output by the model.
Properties
contentstring
The content of the model's reply.
reasoning_contentstring
The chain-of-thought content of the model.
refusalstring
This parameter is currently fixed to null.
rolestring
The role of the message. The value is fixed to assistant.
audioobject
This parameter is currently fixed to null.
function_call (to be deprecated)object
This value is fixed to null. For more information, see the tool_calls parameter.
tool_callsarray
The information about the tool and its input parameters that the model decides to call.
Properties
idstring
The unique identifier for this tool call.
typestring
The tool type. Currently, only function is supported.
functionobject
Tool details
Properties
namestring
The tool name.
argumentsstring
The input parameter information, as a JSON formatted string.
Because the large language model's response is random, the output parameter information may not conform to the function signature. You must validate the parameters before you call the function.
indexinteger
The index of this tool call in the tool_calls array.
createdinteger
The Unix timestamp, in seconds, when the request was created.
modelstring
The model that is used for this request.
objectstring
The value is always chat.completion.
service_tierstring
This parameter is currently fixed to null.
system_fingerprintstring
This parameter is currently fixed to null.
usageobject
The token consumption information for this request.
Properties
completion_tokensinteger
The number of tokens in the model's output.
prompt_tokensinteger
The number of input tokens. For more information, see Additional notes.
total_tokensinteger
The total number of tokens consumed. This is the sum of prompt_tokens and completion_tokens.
completion_tokens_detailsobject (Optional)
A fine-grained classification of output tokens. This field is returned only by some models. Note that text_tokens includes reasoning_tokens — reasoning_tokens is the subset of text_tokens corresponding to the thinking process, so text_tokens minus reasoning_tokens is the number of tokens in the final visible reply. This field is typically returned only when the model outputs a thinking process; it may be null or absent when thinking is not enabled.
Properties
audio_tokensinteger (Optional)
The number of output audio tokens. This field is returned only for audio output models.
reasoning_tokensinteger (Optional)
The number of tokens in the thinking process. This field is returned only for reasoning models. This value is a subset of text_tokens.
text_tokensinteger (Optional)
The number of tokens in the output text. This value already includes reasoning_tokens.
prompt_tokens_detailsobject
A fine-grained classification of input tokens.
Properties
audio_tokensinteger
This parameter is currently fixed to null.
cached_tokensinteger
The number of tokens that hit the cache. For more information about Context Cache, see Context cache.
text_tokensinteger
The number of input text tokens.
image_tokensinteger
The number of input image tokens.
video_tokensinteger
The number of tokens for the input video file or image list.
The number of tokens that are used to create the explicit cache.
cache_creation_input_tokensinteger
The number of tokens that are used to create the explicit cache.
cache_typestring
When you use explicit cache, the parameter value is ephemeral. Otherwise, this parameter does not exist.
x_toolsobject (Optional)
Web search usage statistics. Returned only when include_tool_usage is true in the request and a web search is actually triggered.
Properties
searchobject (Optional)
Web search usage. Returned when web search is enabled and a retrieval is actually triggered.
Properties
countinteger
The number of times web search was triggered in this request. When the agent search strategy is used, the model can perform multiple retrieval rounds, so this value may be greater than 1.
This value is set during the intent-detection stage. It is also counted when the rate limit is exceeded or retrieval returns no results, so it does not mean retrieval actually completed and is not a basis for billing or reconciliation. For details, see The billed count does not match the count field.
strategystring
The search strategy actually used for this web search. The value matches search_options.search_strategy in the request, such as turbo, max, or agent.
Basic response
{
"choices": [
{
"message": {
"role": "assistant",
"content": "I am a large-scale language model developed by Alibaba Cloud. My name is Qwen."
},
"finish_reason": "stop",
"index": 0,
"logprobs": null
}
],
"object": "chat.completion",
"usage": {
"prompt_tokens": 3019,
"completion_tokens": 104,
"total_tokens": 3123,
"prompt_tokens_details": {
"cached_tokens": 2048
}
},
"created": 1735120033,
"system_fingerprint": null,
"model": "qwen3.8-max",
"id": "chatcmpl-6ada9ed2-7f33-9de2-8bb0-78bd4035025a"
}
Web search response
When include_tool_usage is set to true and a web search is actually triggered, the x_tools field is added to usage:
{
"id": "chatcmpl-4233d020-62cd-949f-94e2-444b97503856",
"object": "chat.completion",
"created": 1792037298,
"model": "qwen3.8-max",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The Hangzhou Asian Games (the 19th Asian Games) were held in 2023, from September 23 to October 8, 2023."
},
"finish_reason": "stop",
"logprobs": null
}
],
"usage": {
"prompt_tokens": 1905,
"total_tokens": 1987,
"completion_tokens": 82,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 1905
},
"x_tools": {
"search": {
"count": 1,
"strategy": "turbo"
}
}
}
}
Chat response chunk object (streaming output)
idstring
The unique identifier for this call. Each chunk object has the same ID.
choicesarray
An array of content generated by the model, which can contain one or more objects. If the include_usage parameter is set to true, choices is an empty array in the last chunk.
Properties
deltaobject
The incremental object of the request.
Properties
contentstring
The incremental message content.
reasoning_contentstring
The incremental chain-of-thought content.
function_callobject
This value defaults to null. For more information, see the tool_calls parameter.
audioobject
The reply that is generated when you use the Qwen-Omni model.
Properties
datastring
The incremental Base64-encoded audio data.
expires_atinteger
The timestamp when the request was created.
refusalobject
This parameter is currently fixed to null.
rolestring
The role of the incremental message object. It has a value only in the first chunk.
tool_callsarray
The information about the tool and its input parameters that the model decides to call.
Properties
indexinteger
The index of this tool call in the tool_calls array.
idstring
The unique identifier for this tool call.
functionobject
The information about the called tool.
Properties
argumentsstring
The incremental input parameters. The arguments from all chunks are concatenated to form the complete set of input parameters.
Because the large language model's response is random, the output parameter information may not conform to the function signature. You must validate the parameters before you call the function.
namestring
The tool name. It has a value only in the first chunk.
typestring
The tool type. Currently, only function is supported.
finish_reasonstring
The reason why the model stopped generating. The value can be one of the following:
stop: The model stopped generating because it triggered the stop parameter in the input or stopped naturally.
The value is null until the generation is complete.
length: The model stopped generating because the generation length is too long.
tool_calls: The model stopped generating because a tool needs to be called.
indexinteger
The index of the current response in the choices array. When the input parameter n is greater than 1, you can use this parameter to concatenate the complete content that corresponds to different responses.
logprobsobject
The probability information of the current object.
Properties
contentarray
An array of tokens with log probability information.
Properties
tokenstring
The current token.
bytesarray
A list of the raw UTF-8 bytes of the current token. This is helpful when you process emojis and Chinese characters.
logprobfloat
The log probability of the current token. A null value indicates an extremely low probability.
top_logprobsarray
The most likely tokens at the current token position and their log probabilities. The number of elements is consistent with the top_logprobs input parameter.
Properties
tokenstring
The current token.
bytesarray
A list of the raw UTF-8 bytes of the current token. This is helpful when you process emojis and Chinese characters.
logprobfloat
The log probability of the current token. A null value indicates an extremely low probability.
createdinteger
The timestamp when this request was created. Each chunk has the same timestamp.
modelstring
The model that is used for this request.
objectstring
The value is always chat.completion.chunk.
service_tierstring
This parameter is currently fixed to null.
system_fingerprintstring
This parameter is currently fixed to null.
usageobject
The tokens consumed by this request. It is displayed only in the last chunk when include_usage is set to true.
Properties
completion_tokensinteger
The number of tokens in the model's output.
prompt_tokensinteger
The number of input tokens.
total_tokensinteger
The total number of tokens, which is the sum of prompt_tokens and completion_tokens.
completion_tokens_detailsobject (Optional)
Detailed information about the output tokens. This field is returned only by some models. Note that text_tokens includes reasoning_tokens — reasoning_tokens is the subset of text_tokens corresponding to the thinking process, so text_tokens minus reasoning_tokens is the number of tokens in the final visible reply. This field is typically returned only when the model outputs a thinking process; it may be null or absent when thinking is not enabled.
Properties
audio_tokensinteger (Optional)
The number of output audio tokens. This field is returned only for audio output models.
reasoning_tokensinteger (Optional)
The number of tokens in the thinking process. This field is returned only for reasoning models. This value is a subset of text_tokens.
text_tokensinteger (Optional)
The number of output text tokens. This value already includes reasoning_tokens.
prompt_tokens_detailsobject
A fine-grained classification of input tokens.
Properties
audio_tokensinteger
The number of input audio tokens.
The number of audio tokens in a video file is returned in this parameter.
text_tokensinteger
The number of input text tokens.
video_tokensinteger
The number of tokens for the input video, which can be an image list or a video file.
image_tokensinteger
The number of input image tokens.
cached_tokensinteger
The number of tokens that hit the cache. For more information about Context Cache, see Context cache.
The number of tokens that are used to create the explicit cache.
cache_creation_input_tokensinteger
The number of tokens that are used to create the explicit cache.
cache_typestring
The cache type. The value is fixed to ephemeral.
x_toolsobject (Optional)
Web search usage statistics. Returned only when include_tool_usage is true in the request and a web search is actually triggered. It appears with usage in the last chunk.
Properties
searchobject (Optional)
Web search usage. Returned when web search is enabled and a retrieval is actually triggered.
Properties
countinteger
The number of times web search was triggered in this request. When the agent search strategy is used, the model can perform multiple retrieval rounds, so this value may be greater than 1.
This value is set during the intent-detection stage. It is also counted when the rate limit is exceeded or retrieval returns no results, so it does not mean retrieval actually completed and is not a basis for billing or reconciliation. For details, see The billed count does not match the count field.
strategystring
The search strategy actually used for this web search. The value matches search_options.search_strategy in the request, such as turbo, max, or agent.
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":"","function_call":null,"refusal":null,"role":"assistant","tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":"I am","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":" a large-scale","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":" language","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":" model from Alibaba","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":" Cloud. My name","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":" is Qwen","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":".","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":null,"index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[{"delta":{"content":"","function_call":null,"refusal":null,"role":null,"tool_calls":null},"finish_reason":"stop","index":0,"logprobs":null}],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":null}
{"id":"chatcmpl-e30f5ae7-3063-93c4-90fe-beb5f900bd57","choices":[],"created":1735113344,"model":"qwen3.8-max","object":"chat.completion.chunk","service_tier":null,"system_fingerprint":null,"usage":{"completion_tokens":17,"prompt_tokens":22,"total_tokens":39,"completion_tokens_details":null,"prompt_tokens_details":{"audio_tokens":null,"cached_tokens":0}}}
When include_tool_usage is set to true and a web search is actually triggered, the x_tools field is added to usage in the last chunk: