Deep thinking

Updated at:

Deep thinking models reason before responding, improving accuracy on complex tasks like logical reasoning and math.

This article describes how to call the Deep Think model via the OpenAI-compatible Chat Completion interface or the DashScope interface. For Responses API usage, see: Deep Think.

Demo

The following is a conversation example of the Deep Think model, showing how the model first performs reasoning and then gives an answer.

User Question

9.9 and 9.11, which is larger

Thinking Process(reasoning_content field)

First, the user's question is: "9.9 and 9.11, which is larger", which appears to be comparing two numbers: 9.9 and 9.11.

I need to understand the meaning of these numbers. In mathematics, 9.9 is equivalent to 9.90, and 9.11 is 9.11.

To compare them, I should treat them as decimals. 9.9 is 9 + 9/10 = 9.9, while 9.11 is 9 + 11/100 = 9.11.

Now, compare 9.9 and 9.11: 9.9 is equal to 9.90 (because 9.9 = 9.90), 9.11 is 9.11. Now, compare 9.90 with 9.11: 9.90 is greater than 9.11, because 90/100 > 11/100.

More precisely: 9.9 = 99/10 = 990/100, 9.11 = 911/100, compare 990/100 with 911/100, obviously 990 > 911, so 990/100 > 911/100, therefore 9.9 > 9.11.

I can also directly look at the decimal part: the decimal part of 9.9 is 0.9, the decimal part of 9.11 is 0.11. 0.9 is greater than 0.11, because 0.9 = 0.90 > 0.11.

So, 9.9 is greater than 9.11.

Model answer(content field)

Conclusion: 9.9 is greater than 9.11.

You can also open a model in the Experience Center of the Model Studio console, turn on Deep Thinking, and view the reasoning process directly.

Usage

Bailian Deep Think Model is divided into two modes:

  • Hybrid thinking mode: You can Enable or Disable thinking per request; the control Parameter varies by Model. The following example uses enable_thinking, with the following values:

    • set totrue: the Model thinks first and then replies;
    • set tofalse: the Model replies directly;

    OpenAI Compatible

    # 导入依赖与创建客户端...
    completion = client.chat.completions.create(
        model="qwen3.8-max", # 选择模型
        messages=[{"role": "user", "content": "你是谁"}],
        # 由于 enable_thinking 非 OpenAI 标准参数,需要通过 extra_body 传入
        extra_body={"enable_thinking":True},
        # 流式输出方式调用
        stream=True,
        # 使流式返回的最后一个数据包包含Token消耗信息
        stream_options={
            "include_usage": True
        }
    )
    

    DashScope

    Qwen3.5 series DashScope API uses a multimodal interface; the following example will return an Error url error. For the Calling method, see Enable/Disable thinking mode.

    # Import dependencies and create the client...
    
    response = client.multimodal.chat.create(
        # You can replace it with another deep thinking model as needed
        model="qwen3.8-max",
        messages=messages,
        enable_thinking=True,
        stream=True,
        # Streaming output is incremental by default: each chunk contains only the newly generated content.
    )
    
  • Only Think Mode: The Model always thinks before replying and cannot be disabled. Except that no need to set the enable_thinking Parameter, the request format is consistent with the Hybrid Think Mode.

The thinking content is returned through thereasoning_content Field, and the reply content is returned through thecontent Field. Deep Think requires additional reasoning time. The examples in this article use stream calling by default (Recommend, you can view the Thinking Process in real time and avoid long waits). The commercial version Deep Think Model also supports non-stream (synchronous) Output. For the usage and precautions, see the FAQ below; some Models (such as qwen3.5-122b-a10b, qwen3.5-27b and other open-source versions) only support Stream, and non-stream calling will report an Error.

Supported Models

Qwen3.8

Qwen3.8 Max Series (Hybrid thinking mode, Default Enable thinking mode): qwen3.8-max, qwen3.8-max-0902

Qwen3.8 Flash series (Hybrid thinking mode, Default Enable thinking mode): qwen3.8-flash

Qwen3.8 open source series (Hybrid thinking mode, Default Enable thinking mode): qwen3.8-27b

Qwen3.8 open source series (Only supports thinking mode): qwen3.8-2.4t-a95b

Qwen3.8 Omni series (Hybrid thinking mode, Default Enable thinking mode): qwen3.8-omni-flash. Pass reasoning_effort to adjust thinking intensity. For more information, see thinking mode configuration.

Qwen3.7

Qwen3.7 Max series (Hybrid thinking mode, Default Enable thinking mode): qwen3.7-max, qwen3.7-max-2026-05-20, qwen3.7-max-2026-06-08

Qwen3.7 Max series (Only supports thinking mode): qwen3.7-max-preview, qwen3.7-max-2026-05-17

Qwen3.7 Plus series (hybrid thinking mode, thinking mode enabled by default): qwen3.7-plus, qwen3.7-plus-2026-05-26

Qwen3.7 Flash series (hybrid thinking mode, thinking mode enabled by default): qwen3.7-flash, qwen3.7-flash-2026-07-15

Qwen3.6

Qwen3.6 Plus Series (Hybrid thinking mode, thinking mode enabled by default): qwen3.6-plus, qwen3.6-plus-2026-04-02

Qwen3.6 Flash Series (Hybrid thinking mode, thinking mode enabled by default): qwen3.6-flash, qwen3.6-flash-2026-04-16

Qwen3.6 Open Source Edition: qwen3.6-35b-a3b

Qwen3.5

  • Commercial Edition
    • Qwen3.5 Plus Series (Hybrid thinking mode, Enable thinking mode by default): qwen3.5-plus, qwen3.5-plus-2026-02-15
    • Qwen3.5 Flash series (hybrid thinking mode, Enable thinking mode by default): qwen3.5-flash, qwen3.5-flash-2026-02-23
  • Open-source Version
    • hybrid thinking mode, Enable thinking mode by default: qwen3.5-397b-a17b, qwen3.5-122b-a10b, qwen3.5-27b, qwen3.5-35b-a3b

Kimi

  • Alibaba Cloud Bailian deployment

    • hybrid thinking mode, Disable thinking mode by default: kimi-k2.6, kimi-k2.5
    • Hybrid thinking mode, thinking mode enabled by default: kimi-k3.1-pro, kimi-k3
    • thinking mode only: kimi-k2.7-code
  • Moonshot AI deployed

    • Hybrid thinking mode, thinking mode enabled by default: kimi/kimi-k2.6, kimi/kimi-k2.5
    • Thinking mode only: kimi/kimi-k3.1-pro, kimi/kimi-k3.1-pro-highspeed, kimi/kimi-k3, kimi/kimi-k2.7-code-highspeed, kimi/kimi-k2.7-code

Qwen3

  • Qwen Plus series (Hybrid thinking mode, thinking mode disabled by default): qwen-plus, qwen-plus-latest, qwen-plus-2025-04-28 and later snapshot models
  • Qwen Flash series (Hybrid thinking mode, thinking mode disabled by default): qwen-flash, qwen-flash-2025-07-28 and later snapshot models

DeepSeek

  • Alibaba Cloud Bailian deployment

    • deepseek-v4.1-flash-1017 supports deep thinking.
    • Hybrid thinking mode, thinking mode enabled by default: deepseek-v4.1-flash, deepseek-v4-pro
    • Thinking-only mode: deepseek-r1 distilled models
  • SiliconFlow deployment

    • Mixed thinking mode, thinking mode disabled by default: siliconflow/deepseek-v3.2, siliconflow/deepseek-v3.1-terminus
    • Only thinking mode: siliconflow/deepseek-r1-0528
  • Kuaishou Wanqing deployment

    • Mixed thinking mode, thinking mode disabled by default: vanchin/deepseek-v3.2-think, vanchin/deepseek-v3.1-terminus
    • Only thinking mode: vanchin/deepseek-r1

GLM

  • Only thinking mode: glm-5.3
  • Mixed thinking mode, thinking mode enabled by default: glm-5.2, glm-5.2-fast-preview, glm-5.1, glm-5

MiniMax

  • Alibaba Cloud Bailian deployment

    • Only thinking mode: MiniMax-M2.5
  • Xiyu Technology deployment

    • Thinking mode only: MiniMax/MiniMax-M3.1-Flash

      NoteMiniMax/MiniMax-M3.1-Flash always performs thinking and cannot disable it. Set reasoning_effort to low, medium, high, xhigh, or max. The default value is max.

    • Hybrid thinking mode: MiniMax/MiniMax-M3

      NoteMiniMax/MiniMax-M3 uses the thinking parameter to control thinking mode. Set it to adaptive (default) or disabled. For more information, see MiniMax.

    • Thinking mode only: MiniMax/MiniMax-M2.7, MiniMax/MiniMax-M2.5, MiniMax/MiniMax-M2.1

Stepfun

Thinking mode only: stepfun/step-3.7-flash, stepfun/step-5-preview

Ling

Hybrid thinking mode, thinking mode enabled by default: antdigital/Ling-3.1-flash

Quick Start

API Use prerequisite: alreadyObtain and Configure API Keyand completeConfigure API Key to environment variables. If Pass SDK Calling, needInstall OpenAI Or DashScope SDK(DashScope Java SDK requires no lower than 2.19.4 Version).

The following code takes stream Calling qwen3.8-max Enable thinking mode as an example.

OpenAI Compatible

Python

Sample Code

from openai import OpenAI
import os

# 初始化OpenAI客户端
client = OpenAI(
    # 如果没有配置环境变量,请用阿里云百炼API Key替换:api_key="sk-xxx"
    # 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

messages = [{"role": "user", "content": "你是谁"}]

completion = client.chat.completions.create(
    model="qwen3.8-max",  # 您可以按需更换为其它深度思考模型
    messages=messages,
    extra_body={"enable_thinking": True},
    stream=True,
    stream_options={
        "include_usage": True
    },
)

reasoning_content = ""  # 完整思考过程
answer_content = ""  # 完整回复
is_answering = False  # 是否进入回复阶段
print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")

for chunk in completion:
    if not chunk.choices:
        print("\nUsage:")
        print(chunk.usage)
        continue

    delta = chunk.choices[0].delta

    # 只收集思考内容
    if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
        if not is_answering:
            print(delta.reasoning_content, end="", flush=True)
        reasoning_content += delta.reasoning_content

    # 收到content,开始进行回复
    if hasattr(delta, "content") and delta.content:
        if not is_answering:
            print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
            is_answering = True
        print(delta.content, end="", flush=True)
        answer_content += delta.content

Response

====================思考过程====================

好的,用户问“你是谁”,我需要给出一个准确且友好的回答。首先,我要确认自己的身份,即千问,由阿里巴巴集团旗下的通义实验室研发。接下来,应该说明我的主要功能,比如回答问题、创作文字、逻辑推理等。同时,要保持语气亲切,避免过于技术化,让用户感觉轻松。还要注意不要使用复杂术语,确保回答简洁明了。另外,可能需要加入一些互动元素,邀请用户提问,促进进一步交流。最后,检查是否有遗漏的重要信息,比如我的中文名称“千问”和英文名称“Qwen”,以及所属公司和实验室。确保回答全面且符合用户期望。
====================完整回复====================

你好!我是千问,是阿里巴巴集团旗下的通义实验室自主研发的超大规模语言模型。我可以回答问题、创作文字、进行逻辑推理、编程等,旨在为用户提供高质量的信息和服务。你可以叫我Qwen,或者直接叫我千问。有什么我可以帮你的吗?

Node.js

Sample Code

import OpenAI from "openai";
import process from 'process';

// 初始化 openai 客户端
const openai = new OpenAI({
    // 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
    apiKey: process.env.DASHSCOPE_API_KEY, // 从环境变量读取
    // 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

let reasoningContent = '';
let answerContent = '';
let isAnswering = false;

async function main() {
    try {
        const messages = [{ role: 'user', content: '你是谁' }];
        const stream = await openai.chat.completions.create({
            model: 'qwen3.8-max',
            messages,
            stream: true,
            enable_thinking: true
        });
        console.log('\n' + '='.repeat(20) + '思考过程' + '='.repeat(20) + '\n');

        for await (const chunk of stream) {
            if (!chunk.choices?.length) {
                console.log('\nUsage:');
                console.log(chunk.usage);
                continue;
            }

            const delta = chunk.choices[0].delta;

            // 只收集思考内容
            if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) {
                if (!isAnswering) {
                    process.stdout.write(delta.reasoning_content);
                }
                reasoningContent += delta.reasoning_content;
            }

            // 收到content,开始进行回复
            if (delta.content !== undefined && delta.content) {
                if (!isAnswering) {
                    console.log('\n' + '='.repeat(20) + '完整回复' + '='.repeat(20) + '\n');
                    isAnswering = true;
                }
                process.stdout.write(delta.content);
                answerContent += delta.content;
            }
        }
    } catch (error) {
        console.error('Error:', error);
    }
}

main();

Response

====================思考过程====================

好的,用户问“你是谁”,我需要回答我的身份。首先,我应该明确说明我是千问,由阿里云开发的超大规模语言模型。接下来,可以提到我的主要功能,比如回答问题、创作文字、逻辑推理等。还要强调我的多语言支持,包括中文和英文,这样用户知道我可以处理不同语言的请求。另外,可能需要解释一下我的应用场景,比如学习、工作和生活中的帮助。不过用户的问题比较直接,可能不需要太详细的信息,保持简洁明了。同时,要确保语气友好,邀请用户进一步提问。检查有没有遗漏的重要信息,比如我的版本或最新更新,但可能用户不需要那么详细。最后,确认回答准确无误,没有错误信息。
====================完整回复====================

我是千问,是阿里巴巴集团旗下的通义实验室自主研发的超大规模语言模型。我能够回答问题、创作文字、逻辑推理、编程等多种任务,支持中英文等多种语言。如果你有任何问题或需要帮,欢迎随时告诉我!

HTTP

Sample Code

curl

# ======= 重要提示 =======
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
# 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
# === 执行时请删除该注释 ===
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": "user",
            "content": "你是谁"
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    },
    "enable_thinking": true
}'

Response

data: {"choices":[{"delta":{"content":null,"role":"assistant","reasoning_content":""},"index":0,"logprobs":null,"finish_reason":null}],"object":"chat.completion.chunk","usage":null,"created":1745485391,"system_fingerprint":null,"model":"qwen3.8-max","id":"chatcmpl-e2edaf2c-8aaf-9e54-90e2-b21dd5045503"}

.....

data: {"choices":[{"finish_reason":"stop","delta":{"content":"","reasoning_content":null},"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1745485391,"system_fingerprint":null,"model":"qwen3.8-max","id":"chatcmpl-e2edaf2c-8aaf-9e54-90e2-b21dd5045503"}

data: {"choices":[],"object":"chat.completion.chunk","usage":{"prompt_tokens":10,"completion_tokens":360,"total_tokens":370,"completion_tokens_details":{"reasoning_tokens":286}},"created":1745485391,"system_fingerprint":null,"model":"qwen3.8-max","id":"chatcmpl-e2edaf2c-8aaf-9e54-90e2-b21dd5045503"}

data: [DONE]

DashScope

The DashScope API of the Qwen3.5 series uses a multimodal interface, and the following examples will raise an error url error. For the Calling method, please see Enable/Disable Thinking Mode.

Python

Sample Code

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://help.aliyun.com/en/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

messages = [{"role": "user", "content": [{"text": "你是谁?"}]}]

completion = client.multimodal.chat.create(
    # You can replace it with another deep thinking model as needed
    model="qwen3.8-max",
    messages=messages,
    enable_thinking=True,
    stream=True,
    # Streaming output is incremental by default: each chunk contains only the newly generated content.
)

# Complete thinking process
reasoning_content = ""
# Complete response
answer_content = ""
# Whether the thinking process has ended and the response has started
is_answering = False

print("=" * 20 + "思考过程" + "=" * 20)

for chunk in completion:
    # Get the content of the current chunk (streaming output is incremental by default)
    content_text = chunk.choices[0].delta.content or ""
    reasoning_text = chunk.choices[0].delta.reasoning_content or ""
    # If both the thinking process and the response are empty, ignore this chunk
    if content_text == "" and reasoning_text == "":
        pass
    else:
        # If this is the thinking process
        if reasoning_text != "" and content_text == "":
            print(reasoning_text, end="", flush=True)
            reasoning_content += reasoning_text
        # If this is the response
        elif content_text != "":
            if not is_answering:
                print("\n" + "=" * 20 + "完整回复" + "=" * 20)
                is_answering = True
            print(content_text, end="", flush=True)
            answer_content += content_text

# If you want to print the complete thinking process and complete response, uncomment the following code
# print("=" * 20 + "完整思考过程" + "=" * 20 + "\n")
# print(f"{reasoning_content}")
# print("=" * 20 + "完整回复" + "=" * 20 + "\n")
# print(f"{answer_content}")

Response

====================思考过程====================
好的,用户问:“你是谁?”我需要回答这个问题。首先,我要明确自己的身份,即千问,由阿里云开发的超大规模语言模型。接下来,要说明我的功能和用途,比如回答问题、创作文字、逻辑推理等。同时,要强调我的目标是成为用户的得力助手,提供帮助和支持。

在表达时,要保持口语化,避免使用专业术语或复杂句式。可以加入一些亲切的语气词,比如“你好呀~”,让对话更自然。另外,要确保信息准确,不遗漏关键点,比如我的开发者、主要功能和使用场景。

还要考虑用户可能的后续问题,比如具体的应用例子或技术细节,所以在回答中可以适当埋下伏笔,引导用户进一步提问。例如,提到“无论是日常生活的疑问还是专业领域的问题,我都能尽力提供帮助”,这样既全面又开放。

最后,检查回答是否流畅,有没有重复或冗余的信息,确保简洁明了。同时,保持友好和专业的平衡,让用户感受到既亲切又可靠。
====================完整回复====================
你好呀~我是千问,是阿里云开发的一款超大规模语言模型。我能够回答问题、创作文字、进行逻辑推理、编程等等,旨在为用户提供帮助和支持。无论是日常生活的疑问还是专业领域的问题,我都能尽力提供帮助。有什么我可以帮你的吗?

Java

Sample Code

// dashscope SDK的版本 >= 2.19.4
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import java.util.Collections;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import io.reactivex.Flowable;
import java.lang.System;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {
    private static final Logger logger = LoggerFactory.getLogger(Main.class);
    private static StringBuilder reasoningContent = new StringBuilder();
    private static StringBuilder finalContent = new StringBuilder();
    private static boolean isFirstPrint = true;
    // 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
    static {Constants.baseHttpApiUrl="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";}

    private static void handleMultiModalConversationResult(MultiModalConversationResult message) {
        String reasoning = message.getOutput().getChoices().get(0).getMessage().getReasoningContent();
        List<Map<String, Object>> contentList = (List<Map<String, Object>>) message.getOutput().getChoices().get(0).getMessage().getContent();
        String content = (contentList != null && !contentList.isEmpty()) ? (String) contentList.get(0).get("text") : "";

        if (!reasoning.isEmpty()) {
            reasoningContent.append(reasoning);
            if (isFirstPrint) {
                System.out.println("====================思考过程====================");
                isFirstPrint = false;
            }
            System.out.print(reasoning);
        }

        if (!content.isEmpty()) {
            finalContent.append(content);
            if (!isFirstPrint) {
                System.out.println("\n====================完整回复====================");
                isFirstPrint = true;
            }
            System.out.print(content);
        }
    }
    private static MultiModalConversationParam buildMultiModalConversationParam(MultiModalMessage userMsg) {
        return MultiModalConversationParam.builder()
                 // 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
                // 若没有配置环境变量,请用阿里云百炼API Key将下行替换为:.apiKey("sk-xxx")
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .model("qwen3.8-max")
                .enableThinking(true)
                .incrementalOutput(true)
                .messages(Arrays.asList(userMsg))
                .build();
    }
    public static void streamCallWithMessage(MultiModalConversation conv, MultiModalMessage userMsg)
            throws NoApiKeyException, ApiException, InputRequiredException, UploadFileException {
        MultiModalConversationParam param = buildMultiModalConversationParam(userMsg);
        Flowable<MultiModalConversationResult> result = conv.streamCall(param);
        result.blockingForEach(message -> handleMultiModalConversationResult(message));
    }

    public static void main(String[] args) {
        try {
            MultiModalConversation conv = new MultiModalConversation();
            MultiModalMessage userMsg = MultiModalMessage.builder().role(Role.USER.getValue()).content(Arrays.asList(Collections.singletonMap("text", "你是谁?"))).build();
            streamCallWithMessage(conv, userMsg);
//             打印最终结果
//            if (reasoningContent.length() > 0) {
//                System.out.println("\n====================完整回复====================");
//                System.out.println(finalContent.toString());
//            }
        } catch (ApiException | NoApiKeyException | InputRequiredException | UploadFileException e) {
            logger.error("An exception occurred: {}", e.getMessage());
        }
        System.exit(0);
    }
}

Response

====================思考过程====================
好的,用户问“你是谁?”,我需要根据之前的设定来回答。首先,我的角色是千问,阿里巴巴集团旗下的超大规模语言模型。要保持口语化,简洁易懂。

用户可能刚接触我,或者想确认我的身份。应该先直接回答我是谁,然后简要说明我的功能和用途,比如回答问题、创作文字、编程等。还要提到支持多语言,这样用户知道我可以处理不同语言的需求。

另外,根据指导方针,要保持拟人性,所以语气要友好,可能用表情符号增加亲切感。同时,可能需要引导用户进一步提问或使用我的功能,比如问他们需要什么帮助。

需要注意不要使用复杂术语,避免冗长。检查是否有遗漏的关键点,比如多语言支持和具体能力。确保回答符合所有要求,包括口语化和简洁。
====================完整回复====================
你好!我是千问,阿里巴巴集团旗下的超大规模语言模型。我能够回答问题、创作文字,比如写故事、写公文、写邮件、写剧本、逻辑推理、编程等,还能表达观点,玩游戏等。我熟练掌握多种语言,包括但不限于中文、英文、德语、法语、西班牙语等。有什么需要我帮忙的吗?

HTTP

Sample Code

curl

# ======= 重要提示 =======
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
# 以下为北京地域url,若使用新加坡地域的模型,需将url替换为:https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
# === 执行时请删除该注释 ===
curl -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-DashScope-SSE: enable" \
-d '{
    "model": "qwen3.8-max",
    "input":{
        "messages":[
            {
                "role": "user",
                "content": [{"text": "你是谁?"}]
            }
        ]
    },
    "parameters":{
        "enable_thinking": true,
        "incremental_output": true,
        "result_format": "message"
    }
}'

Response

id:1
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"嗯","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":14,"input_tokens":11,"output_tokens":3},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:2
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":",","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":15,"input_tokens":11,"output_tokens":4},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:3
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"用户","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":16,"input_tokens":11,"output_tokens":5},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:4
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"问","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":17,"input_tokens":11,"output_tokens":6},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:5
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"“","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":18,"input_tokens":11,"output_tokens":7},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}
......

id:358
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"帮助","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":373,"input_tokens":11,"output_tokens":362},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:359
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":",","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":374,"input_tokens":11,"output_tokens":363},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:360
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"欢迎","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":375,"input_tokens":11,"output_tokens":364},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:361
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"随时","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":376,"input_tokens":11,"output_tokens":365},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:362
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"告诉我","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":377,"input_tokens":11,"output_tokens":366},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:363
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"!","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":378,"input_tokens":11,"output_tokens":367},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:364
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"","role":"assistant"},"finish_reason":"stop"}]},"usage":{"total_tokens":378,"input_tokens":11,"output_tokens":367},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

Core Capabilities

Switch Thinking/Non-Thinking Mode

Enabling thinking mode improves response quality, but increases response latency and Token consumption. When using a model with hybrid thinking mode, you can dynamically switch based on question complexity without changing the model:

  • Simple tasks (daily chat, simple Q&A): Set enable_thinkingto falseDisable thinking;
  • Complex tasks (logical reasoning, code generation, math problem solving): Set enable_thinkingSet totrueEnable thinking.

OpenAI Compatible

Importantenable_thinkingNon-OpenAI standard parameter. If using the OpenAI Python SDK, pass it via extra_body. In the Node.js SDK, pass it as a top-level parameter.

Python

Sample Code

from openai import OpenAI
import os

# 初始化OpenAI客户端
client = OpenAI(
    # 如果没有配置环境变量,请用阿里云百炼API Key替换:api_key="sk-xxx"
    # 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

messages = [{"role": "user", "content": "你是谁"}]
completion = client.chat.completions.create(
    model="qwen3.8-max",
    messages=messages,
    # 通过 extra_body 设置 enable_thinking 开启思考过程
    extra_body={"enable_thinking": True},
    stream=True,
    stream_options={
        "include_usage": True
    },
)

reasoning_content = ""  # 完整思考过程
answer_content = ""  # 完整回复
is_answering = False  # 是否进入回复阶段
print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")

for chunk in completion:
    if not chunk.choices:
        print("\n" + "=" * 20 + "Token 消耗" + "=" * 20 + "\n")
        print(chunk.usage)
        continue

    delta = chunk.choices[0].delta

    # 只收集思考内容
    if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
        if not is_answering:
            print(delta.reasoning_content, end="", flush=True)
        reasoning_content += delta.reasoning_content

    # 收到content,开始进行回复
    if hasattr(delta, "content") and delta.content:
        if not is_answering:
            print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
            is_answering = True
        print(delta.content, end="", flush=True)
        answer_content += delta.content

Response

====================思考过程====================

嗯,用户问“你是谁”,我需要先确定他们想知道什么。可能他们第一次接触我,或者想确认我的身份。我应该先介绍自己是千问,由通义实验室研发。然后要说明我的功能,比如回答问题、创作文字、编程等,这样用户了解我能提供什么帮助。还要提到我支持多种语言,这样国际用户也会知道他们可以用不同语言交流。最后保持友好,邀请他们提问,这样可以促进进一步互动。要注意简洁明了,避免技术术语太多,让用户容易理解。可能用户需要的是快速了解我的能力,所以重点放在功能和用途上。还要检查有没有遗漏的信息,比如是否要提到阿里巴巴集团,或者更多技术细节。不过用户可能只需要基本的信息,不需要太深入。确保回答友好且专业,同时鼓励用户继续提问。
====================完整回复====================

我是千问,由通义实验室研发的超大规模语言模型。我可以帮助你回答问题、创作文字、编程、表达观点等,支持多语言交流。有什么需要我帮忙的吗?
====================Token 消耗====================

CompletionUsage(completion_tokens=221, prompt_tokens=10, total_tokens=231, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=None, reasoning_tokens=172, rejected_prediction_tokens=None), prompt_tokens_details=PromptTokensDetails(audio_tokens=None, cached_tokens=0))

Node.js

Sample Code

import OpenAI from "openai";
import process from 'process';

// 初始化OpenAI客户端
const openai = new OpenAI({
    // 如果没有配置环境变量,请用阿里云百炼API Key替换:apiKey: "sk-xxx"
    // 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
    apiKey: process.env.DASHSCOPE_API_KEY,
    // 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

let reasoningContent = ''; // 完整思考过程
let answerContent = ''; // 完整回复
let isAnswering = false; // 是否进入回复阶段

async function main() {
    try {
        const messages = [{ role: 'user', content: '你是谁' }];

        const stream = await openai.chat.completions.create({
            model: 'qwen3.8-max',
            messages,
            // 注意:在 Node.js SDK,enable_thinking 这样的非标准参数作为顶层属性传递的,无需放在 extra_body 中
            enable_thinking: true,
            stream: true,
            stream_options: {
                include_usage: true
            },
        });

        console.log('\n' + '='.repeat(20) + '思考过程' + '='.repeat(20) + '\n');

        for await (const chunk of stream) {
            if (!chunk.choices?.length) {
                console.log('\n' + '='.repeat(20) + 'Token 消耗' + '='.repeat(20) + '\n');
                console.log(chunk.usage);
                continue;
            }

            const delta = chunk.choices[0].delta;

            // 只收集思考内容
            if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) {
                if (!isAnswering) {
                    process.stdout.write(delta.reasoning_content);
                }
                reasoningContent += delta.reasoning_content;
            }

            // 收到content,开始进行回复
            if (delta.content !== undefined && delta.content) {
                if (!isAnswering) {
                    console.log('\n' + '='.repeat(20) + '完整回复' + '='.repeat(20) + '\n');
                    isAnswering = true;
                }
                process.stdout.write(delta.content);
                answerContent += delta.content;
            }
        }
    } catch (error) {
        console.error('Error:', error);
    }
}

main();

Response

====================思考过程====================

嗯,用户问“你是谁”,我需要先确定他们想知道什么。可能他们第一次接触我,或者想确认我的身份。我应该先介绍自己的名字和身份,比如千问,英文名Qwen。然后说明我是阿里巴巴集团旗下的通义实验室自主研发的超大规模语言模型。接下来要提到我的功能,比如回答问题、创作文字、编程、表达观点等,这样用户能了解我的用途。还要提到我支持多语言,这样国际用户会觉得有用。最后邀请他们提问,保持友好和开放的态度。注意用简洁易懂的语言,避免技术术语太多。可能用户需要帮助,或者只是好奇,所以回应要亲切,鼓励他们进一步互动。另外,可能需要考虑用户是否有更深层的需求,比如测试我的能力或者寻找特定帮助,但初次回答还是以基本信息和引导为主。保持口语化,不用复杂句子,让信息传达更有效。
====================完整回复====================

你好!我是千问,英文名Qwen,是阿里巴巴集团旗下的通义实验室自主研发的超大规模语言模型。我可以帮助你回答问题、创作文字(比如写故事、写公文、写邮件、写剧本等)、进行逻辑推理、编程,甚至表达观点和玩游戏。我支持多种语言,包括但不限于中文、英文、德语、法语、西班牙语等。

如果你有任何问题或需要帮助,随时告诉我!
====================Token 消耗====================

{
  prompt_tokens: 10,
  completion_tokens: 288,
  total_tokens: 298,
  completion_tokens_details: { reasoning_tokens: 188 },
  prompt_tokens_details: { cached_tokens: 0 }
}

HTTP

Sample Code

curl

# ======= 重要提示 =======
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
# 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
# === 执行时请删除该注释 ===
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": "user",
            "content": "你是谁"
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    },
    "enable_thinking": true
}'

DashScope

Qwen3.5 series DashScope API uses a multimodal interface; the following example will throw an error url error. For the calling method, see Enable/Disable thinking mode.

Python

Sample Code

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://help.aliyun.com/en/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

# Initialize the request parameters
messages = [{"role": "user", "content": [{"text": "你是谁?"}]}]

completion = client.multimodal.chat.create(
    model="qwen3.8-max",
    messages=messages,
    enable_thinking=True,  # Enable the thinking process
    stream=True,           # Enable streaming output (streaming output is incremental by default)
)

reasoning_content = ""  # Complete thinking process
answer_content = ""     # Complete response
is_answering = False    # Whether the response phase has started

print("\n" + "=" * 20 + "思考过程" + "=" * 20 + "\n")

for chunk in completion:
    delta = chunk.choices[0].delta

    # Collect only the thinking content
    if delta.reasoning_content:
        if not is_answering:
            print(delta.reasoning_content, end="", flush=True)
        reasoning_content += delta.reasoning_content

    # Start the response when content arrives
    if delta.content:
        if not is_answering:
            print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
            is_answering = True
        print(delta.content, end="", flush=True)
        answer_content += delta.content

print("\n" + "=" * 20 + "Token 消耗" + "=" * 20 + "\n")
print(chunk.usage)
# After the loop ends, reasoning_content and answer_content contain the complete content
# You can process them further as needed
# print(f"\n\n完整思考过程:\n{reasoning_content}")
# print(f"\n完整回复:\n{answer_content}")

Response

====================思考过程====================

嗯,用户问“你是谁?”,我需要先确定他们想知道什么。可能他们第一次接触我,或者想确认我的身份。首先,我应该介绍自己的名字,千问,然后说明我是通义实验室研发的超大规模语言模型。接下来,可能需要解释我的功能,比如回答问题、创作文字、编程等,这样用户能了解我的用途。还要提到我支持多种语言,这样国际用户也能知道他们可以用不同语言交流。最后,保持友好,邀请他们提问,这样能促进进一步的互动。要注意用简洁易懂的语言,避免技术术语太多,让用户容易理解。可能用户有更深层的需求,比如测试我的能力,或者寻找帮助,所以提供具体的例子会更好,比如写故事、写公文、写邮件等。还要确保回答结构清晰,分点说明功能,但可能不需要用项目符号,而是自然过渡。另外,要强调我是AI助手,没有个人意识,所有回答都基于训练数据,这样避免误解。可能需要检查有没有遗漏的重要信息,比如多模态能力,或者最新的更新,但根据之前的回复,可能不需要太深入。总之,回答要全面但简洁,友好且有帮助,让用户感到被理解和支持。
====================完整回复====================

我是千问,阿里巴巴集团旗下的通义实验室自主研发的超大规模语言模型。我可以帮助你:

1. **回答问题**:无论是学术问题、常识问题还是专业领域问题,我都可以尝试为你解答。
2. **创作文字**:写故事、写公文、写邮件、写剧本等,我都可以帮你完成。
3. **逻辑推理**:我可以帮助你进行逻辑推理和解决问题。
4. **编程**:我可以理解并生成多种编程语言的代码。
5. **多语言支持**:我支持多种语言,包括但不限于中文、英文、德语、法语、西班牙语等。

如果你有任何问题或需要帮助,随时告诉我!
====================Token 消耗====================

{"input_tokens": 11, "output_tokens": 405, "total_tokens": 416, "output_tokens_details": {"reasoning_tokens": 256}, "prompt_tokens_details": {"cached_tokens": 0}}

Java

Sample Code

// dashscope SDK的版本 >= 2.19.4
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import java.util.Collections;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import io.reactivex.Flowable;
import java.lang.System;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {
    private static final Logger logger = LoggerFactory.getLogger(Main.class);
    private static StringBuilder reasoningContent = new StringBuilder();
    private static StringBuilder finalContent = new StringBuilder();
    private static boolean isFirstPrint = true;
    // 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
    static {Constants.baseHttpApiUrl="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";}

    private static void handleMultiModalConversationResult(MultiModalConversationResult message) {
        String reasoning = message.getOutput().getChoices().get(0).getMessage().getReasoningContent();
        List<Map<String, Object>> contentList = (List<Map<String, Object>>) message.getOutput().getChoices().get(0).getMessage().getContent();
        String content = (contentList != null && !contentList.isEmpty()) ? (String) contentList.get(0).get("text") : "";

        if (!reasoning.isEmpty()) {
            reasoningContent.append(reasoning);
            if (isFirstPrint) {
                System.out.println("====================思考过程====================");
                isFirstPrint = false;
            }
            System.out.print(reasoning);
        }

        if (!content.isEmpty()) {
            finalContent.append(content);
            if (!isFirstPrint) {
                System.out.println("\n====================完整回复====================");
                isFirstPrint = true;
            }
            System.out.print(content);
        }
    }
    private static MultiModalConversationParam buildMultiModalConversationParam(MultiModalMessage userMsg) {
        return MultiModalConversationParam.builder()
                // 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
                // 若没有配置环境变量,请用阿里云百炼API Key将下行替换为:.apiKey("sk-xxx")
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .model("qwen3.8-max")
                .enableThinking(true)
                .incrementalOutput(true)
                .messages(Arrays.asList(userMsg))
                .build();
    }
    public static void streamCallWithMessage(MultiModalConversation conv, MultiModalMessage userMsg)
            throws NoApiKeyException, ApiException, InputRequiredException, UploadFileException {
        MultiModalConversationParam param = buildMultiModalConversationParam(userMsg);
        Flowable<MultiModalConversationResult> result = conv.streamCall(param);
        result.blockingForEach(message -> handleMultiModalConversationResult(message));
    }

    public static void main(String[] args) {
        try {
            MultiModalConversation conv = new MultiModalConversation();
            MultiModalMessage userMsg = MultiModalMessage.builder().role(Role.USER.getValue()).content(Arrays.asList(Collections.singletonMap("text", "你是谁?"))).build();
            streamCallWithMessage(conv, userMsg);
//             打印最终结果
//            if (reasoningContent.length() > 0) {
//                System.out.println("\n====================完整回复====================");
//                System.out.println(finalContent.toString());
//            }
        } catch (ApiException | NoApiKeyException | InputRequiredException | UploadFileException e) {
            logger.error("An exception occurred: {}", e.getMessage());
        }
        System.exit(0);
    }
}

Response

====================思考过程====================
嗯,用户问“你是谁?”,我需要先确定他们想了解什么。可能他们想知道我的身份,或者是在测试我的反应。首先,我应该明确回答我是千问,阿里巴巴集团旗下的超大规模语言模型。然后,可能需要简要介绍我的功能,比如回答问题、创作文字、编程等,这样用户能了解我的用途。还要提到我支持多种语言,这样国际用户也会知道他们可以用不同语言交流。最后,保持友好,邀请他们提问,这样他们会觉得亲切,愿意继续互动。要注意回答不要太长,但信息要全面。可能用户还有后续问题,比如我的技术细节或者使用场景,但初次回答应该简洁明了。确保没有使用专业术语,让所有用户都能理解。检查有没有遗漏的重要信息,比如多语言支持和具体功能例子。好的,这样应该能覆盖用户的需求了。
====================完整回复====================
我是千问,阿里巴巴集团旗下的超大规模语言模型。我能够回答问题、创作文字(如写故事、写公文、写邮件、写剧本等)、进行逻辑推理、编程、表达观点、玩游戏等,支持多语言交流,包括但不限于中文、英文、德语、法语、西班牙语等。如果你有任何问题或需要帮助,欢迎随时告诉我!

HTTP

Sample Code

curl

# ======= 重要提示 =======
# 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
# 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
# === 执行时请删除该注释 ===
curl -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-DashScope-SSE: enable" \
-d '{
    "model": "qwen3.8-max",
    "input":{
        "messages":[
            {
                "role": "user",
                "content": [{"text": "你是谁?"}]
            }
        ]
    },
    "parameters":{
        "enable_thinking": true,
        "incremental_output": true,
        "result_format": "message"
    }
}'

Response

id:1
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"嗯","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":14,"input_tokens":11,"output_tokens":3},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:2
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":",","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":15,"input_tokens":11,"output_tokens":4},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:3
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"用户","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":16,"input_tokens":11,"output_tokens":5},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:4
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"问","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":17,"input_tokens":11,"output_tokens":6},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:5
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"“","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":18,"input_tokens":11,"output_tokens":7},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}
......

id:358
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"帮助","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":373,"input_tokens":11,"output_tokens":362},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:359
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":",","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":374,"input_tokens":11,"output_tokens":363},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:360
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"欢迎","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":375,"input_tokens":11,"output_tokens":364},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:361
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"随时","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":376,"input_tokens":11,"output_tokens":365},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:362
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"告诉我","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":377,"input_tokens":11,"output_tokens":366},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:363
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"!","reasoning_content":"","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":378,"input_tokens":11,"output_tokens":367},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

id:364
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"","role":"assistant"},"finish_reason":"stop"}]},"usage":{"total_tokens":378,"input_tokens":11,"output_tokens":367},"request_id":"25d58c29-c47b-9e8d-a0f1-d6c309ec58b1"}

Additionally, Qwen3 open-source hybrid thinking model and the qwen-plus-2025-04-28 modelSupports dynamically controlling the thinking mode through prompts.enable_thinkingWhen true, add the following to the prompt: /no_think to disable thinking; to re-enable it in multi-turn conversations, add to the latest prompt: /think . The Model always follows the latest /think or /no_think instruction.

Limit Thinking Length

Deep thinking models can produce long reasoning processes, which increase latency and consume more tokens. Use the thinking_budget parameter to set the maximum number of tokens for the reasoning process. Once the limit is reached, the model immediately starts generating the response. kimi-k3.1-pro and kimi-k3 do not support this parameter, so it cannot limit their thinking length.

For supported models and their default values, see Chat Completions parameters and DashScope parameters.

The following only lists key parameters. For the complete streaming call code, see Quick Start.

OpenAI compatible

completion = client.chat.completions.create(
    model="qwen3.8-max",
    messages=messages,
    # Set the maximum number of tokens for the reasoning process
    extra_body={"enable_thinking": True, "thinking_budget": 50},
    stream=True,
)

DashScope

completion = client.multimodal.chat.create(
    model="qwen3.8-max",
    messages=messages,
    enable_thinking=True,
    # Set the maximum number of tokens for the reasoning process
    thinking_budget=50,
    stream=True,
)

Pass 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 multi-turn requests.

In multi-turn conversations, preserve_thinking controls whether the model reads from historical assistant messages reasoning_content. When set to true, these thinking contents will be appended to the next round's input. The client needs to provide historical assistant messages and their reasoning_content in the request's messages. The default value of each model is subject to Chat Completions Parameter Description.

ImportantFor supported models and their default values, see Chat Completions parameters and DashScope parameters.

For the models that support this parameter—Qwen3.8 Max, Qwen3.7, Qwen3.6 and Kimi—if the history messages do not contain reasoning_content, enabling this parameter will not cause an error.

After enabling it, the reasoning_content in the history messages will be counted toward the input Token quantity and billing.

OpenAI Compatible

Notepreserve_thinkingNon-OpenAI standard parameter. When using the Python SDK, you must pass it in viaextra_body.

Python

Sample Code

from openai import OpenAI
import os

client = OpenAI(
    # 如果没有配置环境变量,请用阿里云百炼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",
)

# 第一轮对话
messages = [
    {"role": "user", "content": "我需要为一个日均千万消息的电商系统选择消息队列,请推荐"}
]

first_reasoning = ""
first_content = ""
is_answering = False

completion = client.chat.completions.create(
    model="qwen3.8-max",
    messages=messages,
    extra_body={"enable_thinking": True},
    stream=True,
    stream_options={"include_usage": True},
)

print("=" * 20 + "第一轮思考过程" + "=" * 20)

for chunk in completion:
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta
    if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
        first_reasoning += delta.reasoning_content
        if not is_answering:
            print(delta.reasoning_content, end="", flush=True)
    if hasattr(delta, "content") and delta.content:
        if not is_answering:
            print("\n" + "=" * 20 + "第一轮回复" + "=" * 20)
            is_answering = True
        print(delta.content, end="", flush=True)
        first_content += delta.content

# 第二轮对话:传递思考过程,追问模型为什么排除了Kafka
messages = [
    {"role": "user", "content": "我需要为一个日均千万消息的电商系统选择消息队列,请推荐"},
    {
        "role": "assistant",
        "content": first_content,
        "reasoning_content": first_reasoning,
    },
    {"role": "user", "content": "你在对比时为什么排除了Kafka?"},
]

reasoning_content = ""
answer_content = ""
is_answering = False

# preserve_thinking 通过 extra_body 传入
completion = client.chat.completions.create(
    model="qwen3.8-max",
    messages=messages,
    extra_body={
        "enable_thinking": True,
        "preserve_thinking": True,
    },
    stream=True,
    stream_options={"include_usage": True},
)

print("\n" + "=" * 20 + "第二轮思考过程" + "=" * 20)

for chunk in completion:
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta
    if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
        if not is_answering:
            print(delta.reasoning_content, end="", flush=True)
        reasoning_content += delta.reasoning_content
    if hasattr(delta, "content") and delta.content:
        if not is_answering:
            print("\n" + "=" * 20 + "第二轮回复" + "=" * 20)
            is_answering = True
        print(delta.content, end="", flush=True)
        answer_content += delta.content

Response

====================第一轮思考过程====================
用户需要为日均千万消息的电商系统选择消息队列。让我从吞吐量、可靠性、延迟消息、事务支持等维度对比主流方案...

RocketMQ:阿里电商场景验证,原生支持事务消息和延迟消息,分区级严格有序...
Kafka:极高吞吐量,但无原生事务消息和延迟消息支持,需自研补偿机制...
RabbitMQ:延迟低,但集群扩展能力有限,峰值万级TPS...
====================第一轮回复====================
综合电商场景的核心需求(事务消息、延迟消息、顺序性、峰值应对),推荐 Apache RocketMQ。如果团队已有 Kafka 生态或需强实时分析能力,Kafka 也是可行方案。
====================第二轮思考过程====================
用户在追问为什么排除了Kafka。回顾我的历史思考过程,我并没有排除Kafka,而是给了它4星评分。让我参考之前的详细对比分析来解释...

在上一轮思考中,我对比了RocketMQ和Kafka在事务消息、延迟消息、顺序性方面的差异。Kafka的劣势主要在于需要额外架构设计来补齐电商特有语义...
====================第二轮回复====================
我并没有排除Kafka。Kafka在吞吐量和生态方面表现优秀,之所以RocketMQ评分略高,是因为电商核心链路的"开箱即用"特性匹配度:RocketMQ原生支持事务消息和延迟消息,而Kafka需要通过Outbox Pattern等架构模式自行实现。如果团队已有Kafka生态,它完全能胜任千万级消息场景。

Node.js

Sample Code

import OpenAI from "openai";
import process from 'process';

const openai = new OpenAI({
    // 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

async function main() {
    // 第一轮对话
    let firstReasoning = '';
    let firstContent = '';
    let isAnswering = false;

    const stream1 = await openai.chat.completions.create({
        model: 'qwen3.8-max',
        messages: [{ role: 'user', content: '我需要为一个日均千万消息的电商系统选择消息队列,请推荐' }],
        stream: true,
        enable_thinking: true
    });

    console.log('='.repeat(20) + '第一轮思考过程' + '='.repeat(20));

    for await (const chunk of stream1) {
        if (!chunk.choices?.length) continue;
        const delta = chunk.choices[0].delta;
        if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) {
            firstReasoning += delta.reasoning_content;
            if (!isAnswering) process.stdout.write(delta.reasoning_content);
        }
        if (delta.content !== undefined && delta.content) {
            if (!isAnswering) {
                console.log('\n' + '='.repeat(20) + '第一轮回复' + '='.repeat(20));
                isAnswering = true;
            }
            process.stdout.write(delta.content);
            firstContent += delta.content;
        }
    }

    // 第二轮对话:传递思考过程
    let reasoningContent = '';
    let answerContent = '';
    isAnswering = false;

    const stream2 = await openai.chat.completions.create({
        model: 'qwen3.8-max',
        messages: [
            { role: 'user', content: '我需要为一个日均千万消息的电商系统选择消息队列,请推荐' },
            {
                role: 'assistant',
                content: firstContent,
                reasoning_content: firstReasoning
            },
            { role: 'user', content: '你在对比时为什么排除了Kafka?' }
        ],
        stream: true,
        enable_thinking: true,
        // preserve_thinking 作为顶层参数传入
        preserve_thinking: true
    });

    console.log('\n' + '='.repeat(20) + '第二轮思考过程' + '='.repeat(20));

    for await (const chunk of stream2) {
        if (!chunk.choices?.length) continue;
        const delta = chunk.choices[0].delta;
        if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) {
            if (!isAnswering) process.stdout.write(delta.reasoning_content);
            reasoningContent += delta.reasoning_content;
        }
        if (delta.content !== undefined && delta.content) {
            if (!isAnswering) {
                console.log('\n' + '='.repeat(20) + '第二轮回复' + '='.repeat(20));
                isAnswering = true;
            }
            process.stdout.write(delta.content);
            answerContent += delta.content;
        }
    }
}

main();

Response

====================第一轮思考过程====================
用户需要为日均千万消息的电商系统选择消息队列。让我从吞吐量、可靠性、延迟消息、事务支持等维度对比主流方案...
====================第一轮回复====================
综合电商场景的核心需求,推荐 Apache RocketMQ。如果团队已有 Kafka 生态,Kafka 也是可行方案。
====================第二轮思考过程====================
用户追问为什么排除了Kafka。参考我之前的思考过程,我并没有排除Kafka...
====================第二轮回复====================
我并没有排除Kafka。Kafka在吞吐量和生态方面表现优秀,之所以RocketMQ评分略高,是因为电商核心链路的"开箱即用"特性匹配度。

HTTP

Sample Code

curl

# 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
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": "user",
            "content": "我需要为一个日均千万消息的电商系统选择消息队列,请推荐"
        },
        {
            "role": "assistant",
            "content": "综合电商场景的核心需求,推荐 Apache RocketMQ。",
            "reasoning_content": "用户需要为日均千万消息的电商系统选择消息队列。RocketMQ原生支持事务消息和延迟消息,更适合电商场景。Kafka吞吐量极高但需自研补偿机制。"
        },
        {
            "role": "user",
            "content": "你在对比时为什么排除了Kafka?"
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    },
    "enable_thinking": true,
    "preserve_thinking": true
}'

Response

data: {"choices":[{"delta":{"content":null,"role":"assistant","reasoning_content":""},"index":0,"logprobs":null,"finish_reason":null}],"object":"chat.completion.chunk","usage":null,"created":1743523200,"system_fingerprint":null,"model":"qwen3.8-max","id":"chatcmpl-example-001"}

.....

data: {"choices":[{"finish_reason":"stop","delta":{"content":"","reasoning_content":null},"index":0,"logprobs":null}],"object":"chat.completion.chunk","usage":null,"created":1743523200,"system_fingerprint":null,"model":"qwen3.8-max","id":"chatcmpl-example-001"}

data: {"choices":[],"object":"chat.completion.chunk","usage":{"prompt_tokens":3463,"completion_tokens":2387,"total_tokens":5850,"completion_tokens_details":{"reasoning_tokens":1347}},"created":1743523200,"system_fingerprint":null,"model":"qwen3.8-max","id":"chatcmpl-example-001"}

data: [DONE]

DashScope

NoteJava SDK does not currently support thepreserve_thinkingParameter. When calling via HTTP, please putpreserve_thinkinginto theparametersobject.

Python

Sample Code

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://help.aliyun.com/en/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

# First round of the conversation
messages = [
    {"role": "user", "content": [{"text": "我需要为一个日均千万消息的电商系统选择消息队列,请推荐"}]}
]

first_reasoning = ""
first_content = ""
is_answering = False

completion = client.multimodal.chat.create(
    model="qwen3.8-max",
    messages=messages,
    enable_thinking=True,
    stream=True,
    # Streaming output is incremental by default: each chunk contains only the newly generated content.
)

print("=" * 20 + "第一轮思考过程" + "=" * 20)

for chunk in completion:
    content_text = chunk.choices[0].delta.content or ""
    reasoning_text = chunk.choices[0].delta.reasoning_content or ""
    if content_text == "" and reasoning_text == "":
        pass
    else:
        if reasoning_text != "" and content_text == "":
            print(reasoning_text, end="", flush=True)
            first_reasoning += reasoning_text
        elif content_text != "":
            if not is_answering:
                print("\n" + "=" * 20 + "第一轮回复" + "=" * 20)
                is_answering = True
            print(content_text, end="", flush=True)
            first_content += content_text

# Second round of the conversation: pass the thinking process
messages = [
    {"role": "user", "content": [{"text": "我需要为一个日均千万消息的电商系统选择消息队列,请推荐"}]},
    {
        "role": "assistant",
        "content": [{"text": first_content}],
        "reasoning_content": first_reasoning,
    },
    {"role": "user", "content": [{"text": "你在对比时为什么排除了Kafka?"}]},
]

reasoning_content = ""
answer_content = ""
is_answering = False

completion = client.multimodal.chat.create(
    model="qwen3.8-max",
    messages=messages,
    enable_thinking=True,
    # Pass the thinking process (preserve_thinking is not an SDK signature parameter, pass it through parameters)
    parameters={"preserve_thinking": True},
    stream=True,
    # Streaming output is incremental by default: each chunk contains only the newly generated content.
)

print("\n" + "=" * 20 + "第二轮思考过程" + "=" * 20)

for chunk in completion:
    content_text = chunk.choices[0].delta.content or ""
    reasoning_text = chunk.choices[0].delta.reasoning_content or ""
    if content_text == "" and reasoning_text == "":
        pass
    else:
        if reasoning_text != "" and content_text == "":
            print(reasoning_text, end="", flush=True)
            reasoning_content += reasoning_text
        elif content_text != "":
            if not is_answering:
                print("\n" + "=" * 20 + "第二轮回复" + "=" * 20)
                is_answering = True
            print(content_text, end="", flush=True)
            answer_content += content_text

Response

====================第一轮思考过程====================
用户需要为日均千万消息的电商系统选择消息队列。让我从吞吐量、可靠性、延迟消息、事务支持等维度对比主流方案...
====================第一轮回复====================
综合电商场景的核心需求,推荐 Apache RocketMQ。如果团队已有 Kafka 生态,Kafka 也是可行方案。
====================第二轮思考过程====================
用户追问为什么排除了Kafka。参考我之前的思考过程,我并没有排除Kafka...
====================第二轮回复====================
我并没有排除Kafka。Kafka在吞吐量和生态方面表现优秀,之所以RocketMQ评分略高,是因为电商核心链路的"开箱即用"特性匹配度。

HTTP

Sample Code

curl

# 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
curl -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-DashScope-SSE: enable" \
-d '{
    "model": "qwen3.8-max",
    "input":{
        "messages":[
            {
                "role": "user",
                "content": [{"text": "我需要为一个日均千万消息的电商系统选择消息队列,请推荐"}]
            },
            {
                "role": "assistant",
                "content": [{"text": "综合电商场景的核心需求,推荐 Apache RocketMQ。"}],
                "reasoning_content": "用户需要为日均千万消息的电商系统选择消息队列。RocketMQ原生支持事务消息和延迟消息,更适合电商场景。Kafka吞吐量极高但需自研补偿机制。"
            },
            {
                "role": "user",
                "content": [{"text": "你在对比时为什么排除了Kafka?"}]
            }
        ]
    },
    "parameters":{
        "enable_thinking": true,
        "preserve_thinking": true,
        "incremental_output": true,
        "result_format": "message"
    }
}'

Response

id:1
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"用户","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":3466,"output_tokens":3,"input_tokens":3463,"output_tokens_details":{"reasoning_tokens":1}},"request_id":"example-request-001"}

id:2
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"追问","role":"assistant"},"finish_reason":"null"}]},"usage":{"total_tokens":3467,"output_tokens":4,"input_tokens":3463,"output_tokens_details":{"reasoning_tokens":2}},"request_id":"example-request-001"}

......

id:200
event:result
:HTTP_STATUS/200
data:{"output":{"choices":[{"message":{"content":"","reasoning_content":"","role":"assistant"},"finish_reason":"stop"}]},"usage":{"total_tokens":5850,"output_tokens":2387,"input_tokens":3463,"output_tokens_details":{"reasoning_tokens":1347}},"request_id":"example-request-001"}

Other Features

Billing Details

  • Thinking content is billed by Output Token.

  • Some hybrid thinking models have different prices in thinking and non-thinking modes. When the model outputs Thinking Process, all Output Tokens (including thinking Tokens and reply Tokens) are billed at the Output price of thinking mode.

    If the model does not output Thinking Process in thinking mode, it is billed at the non-thinking mode price.

FAQ

Q: How to disable thinking mode?

Whether thinking mode can be Disabled depends on the model used:

  • Hybrid thinking mode models (such as qwen3.6-plus, deepseek-v4-pro): Set enable_thinking to false to Disable;
  • Thinking-only mode models (such as glm-5.3, kimi-k2.7-code): cannot be disabled.
  • kimi-k3.1-pro and kimi-k3 enable thinking by default. Set enable_thinking=false to disable it, but keeping it enabled is recommended. For kimi-k3.1-pro, disabling thinking significantly degrades output quality, so keeping it enabled is strongly recommended.

enable_thinking is an extended Parameter of Bailian and does not belong to the OpenAI standard Field. When Using the OpenAI Java SDK, ChatCompletionCreateParams does not natively support this Field, and it needs to be passed through extraBody method:

// enable_thinking 非 OpenAI 标准参数,Java SDK 需通过 extra_body 传递
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
    .model("qwen3.6-plus")
    .messages(List.of(
        ChatCompletionMessageParam.builder()
            .role(ChatCompletionMessageParamRole.USER)
            .content("你好")
            .build()
    ))
    .extraBody(Map.of("enable_thinking", false))
    .build();

client.chat().completions().create(params);

Q: How to confirm whether thinking mode is enabled?

If the Calling latency difference between thinking mode and non-thinking mode is minimal, it indicates that the thinking mode may not be actually Enabled. Troubleshoot with the following steps:

  1. Check whether the enable_thinking=true Parameter is correctly passed in the API request. When Using the OpenAI Java SDK, this Parameter needs to be passed through extraBody Pass in (see the previous example).
  2. Check whether the response contains reasoning_content Field, and confirm that in usage reasoning_tokens is Greater than 0. If it does not contain this Field Or reasoning_tokens=0 indicates that thinking mode is not enabled.
  3. Compare the response time and completion_tokens. After enabling thinking mode, the response will contain reasoning_content Field, and the total time increases significantly (measured about 3 Times of non-thinking mode); if the time difference between the two is minimal, it indicates that thinking mode is not actually effective, please check whether the Parameter is passed in correctly and retry.

Q: How to troubleshoot slow qwen3.7-plus responses?

qwen3.7-plus belongs to the hybrid thinking mode Model, and thinking mode is enabled by Default. The Thinking Process generates a large number of reasoning Tokens (measured at over 60% of the total Output Tokens), so the total time of a single Calling is significantly longer than that of the non-thinking mode. At this time, the Token generation speed itself is not abnormal (measured at about 52-54 Tokens/s); the total time difference mainly comes from the number of Tokens generated by the Thinking Process, rather than the Model Or network slowing down.

Troubleshooting steps:

  1. Confirm whether thinking mode is enabled. qwen3.7-plus is enabled by default, and you can determine this based on whether the response returns reasoning_content field.
  2. View the response usage for completion_tokens and reasoning_tokens. If reasoning_tokens is high, then the long total time is an expected performance of the thinking mode.
  3. If the Thinking Process is not needed, set enable_thinking to false to Disable the thinking mode. After disabling, Output Token is significantly reduced, and measured total time can be reduced by 60%-75%.
  4. If you need to retain the thinking capability, you can switch toStream, to Obtain the first Token faster and view the Thinking Process in real time, avoiding long waits for the complete response.

The usage statistics display the overall time of a single Calling (including the generation time of Thinking Tokens), not the generation latency of a single Token.

Q: How to call deep thinking models in non-streaming (synchronous) mode?

The examples in this article Default to using Stream (Recommend, can view the Thinking Process in real time and avoid long waits). The commercial version Deep Think Model (such as qwen-plus, qwen-flash, etc.) also supports non-stream (synchronous) Output, returning the complete Thinking Process and reply at once.

When changing the stream example to non-stream, please synchronously modify the response parsing code: the non-stream Calling returns the complete Response object (completion), cannot iterate like the stream example via for chunk in completion iterate (otherwise it will report Error 'tuple' object has no attribute 'choices'), but should directly read completion.choices[0].message.reasoning_content(Thinking Process) and completion.choices[0].message.content(reply content). In addition, stream=False cannot set the stream_options Parameter.

The following uses the OpenAI-compatible interface, non-stream Calling of qwen3.8-max with Enable thinking mode as an example:

from openai import OpenAI
import os

client = OpenAI(
    # 如果没有配置环境变量,请用阿里云百炼API Key替换:api_key="sk-xxx"
    # 各地域的API Key不同。获取API Key:https://help.aliyun.com/model-studio/get-api-key
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 以下为华北2(北京)地域的配置,调用时请将{WorkspaceId}替换为真实的业务空间ID,各地域的配置不同。
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="qwen3.8-max",  # 请替换为支持非流式输出的深度思考模型
    messages=[{"role": "user", "content": "你是谁"}],
    extra_body={"enable_thinking": True},
    stream=False,  # 非流式(同步)输出;stream=False 时不能设置 stream_options
)

# 非流式返回完整响应对象,直接读取 message,无需(也不能)迭代
message = completion.choices[0].message
print("=" * 20 + "思考过程" + "=" * 20 + "\n")
print(getattr(message, "reasoning_content", "") or "")
print("\n" + "=" * 20 + "完整回复" + "=" * 20 + "\n")
print(message.content)

Some models (such as qwen3.5-122b-a10b, qwen3.5-27b open-source versions) only support Stream, non-stream Calling will report an error parameter.enable_thinking only support stream call, for such models please Use stream Calling.

Q: How to purchase Tokens after the free quota is exhausted?

Go to Fees and CostsRecharge at the center to maintain sufficient account balance for normal model calling.

After exceeding the free quota, billing occurs automatically at minute-level intervals. For consumption details, go to Bill Details to view.

Q: How to connect Chatbox, Cherry Studio, Cline, or Dify?

Refer to the following steps based on the tool you use:

The following uses common tools as examples; other large model tools follow a similar integration approach.

Chatbox

For more information, see Chatbox.

Cherry Studio

For more information, see Cherry Studio.

Cline

For more information, see Cline.

Dify

For more information, see Dify.

Q: Can I upload images or documents for questioning?

The models covered in this article only support text input. Qwen3-VL, QVQ models support image Deep Think,Qwen- LongModel supports document input.

Q: How to output the thinking process when using LangChain?

Please follow the steps below:

  1. Update dependency libraries

    Update langchain_community and dashscope to the latest version:

pip install -U langchain_community dashscope
  1. Calling Deep Think Model

    Pass the following code to print the Thinking Process and reply content respectively:

from langchain_community.chat_models.tongyi import ChatTongyi
from langchain_core.messages import HumanMessage

chatLLM = ChatTongyi(
    # 您可按需更换为其它深度思考模型
    model="qwen3.8-max",
    model_kwargs={
        "enable_thinking":True
    }
)
completion = chatLLM.stream(
    [HumanMessage(content="你是谁")])
is_answering = False
print("="*20+"思考过程 "+"="*20)
for chunk in completion:
    if chunk.additional_kwargs.get("reasoning_content"):
        print(chunk.additional_kwargs.get("reasoning_content"),end="",flush=True)
    else:
        if not is_answering:
            print("\n"+"="*20+"回复内容"+"="*20)
            is_answering = True
        print(chunk.content,end="",flush=True)

Sample Output:

====================思考过程 ====================
好的,用户问“你是谁”,我需要给出一个准确且友好的回答。首先,我应该介绍自己的名字和基本功能,让用户了解我的用途。然后,可能需要提到我是通义实验室研发的,这样增加权威性。还要说明我能做什么,比如回答问题、创作文字等,这样用户知道可以怎么使用我。同时,保持语气亲切,避免太技术化的术语,让回答更易懂。另外,可能需要检查是否有遗漏的信息,比如多语言支持或者应用场景,但用户的问题比较基础,可能不需要太详细。最后,确保回答简洁明了,不冗长,符合用户的快速获取信息的需求。
====================回复内容====================
我是Qwen3,是阿里巴巴集团旗下的通义实验室自主研发的超大规模语言模型。我可以帮助你回答问题、创作文字(如写故事、公文、邮件、剧本等)、进行逻辑推理、编程,甚至表达观点和玩游戏。我支持多种语言,包括但不限于中文、英文、德语、法语、西班牙语等,旨在为全球用户提供高效、便捷的服务。如果你有任何问题或需要帮助,欢迎随时告诉我!

Q: How to view Token consumption and call count?

Model calls occur withinminutes-levelcan be viewed in monitoring charts. Log in to the Monitoring page (BeijingOrSingapore), select in the left navigation barO&M Management > Monitoringto enter the monitoring overview page, set the query conditions (e.g., select time range, workspace, etc.), then in theModelsarea find the target model and clickView Detailsto view the call statistics of the model. For details, see Monitoring & Alerts docs.

Monitoring data is updated at minute-level and is for reference only; it is not used as a billing basis.

Q: What to do if a long prompt fails to generate or times out?

When calling the model with a long prompt, generation failures or response timeouts usually occur because thinking mode is enabled (enable_thinking set to true). Thinking mode increases processing time, and in long-prompt scenarios this may cause the response to be truncated or the request to time out.

Solution:

  • Disable thinking mode: Set enable_thinking to false, processing time can be reduced from about 50 s to about 30 s.
  • Enable Stream: Set stream to true to avoid the timeout limit of non-streaming calls.
  • Increase the timeout: If you need to keep thinking mode, set the client timeout to 180 s or more.

Q: What to do if a third-party client disconnects after outputting a thinking tag when calling a deep thinking model?

This is a client-side issue, not the Model limiting the Output of the Thinking Process. Bailian platform controls the thinking mode switch via the enable_thinking Parameter, and the reasoning_content Field contains the complete Thinking Process content, and the Model will normally return the thinking content. Disconnections are typically caused by client network fluctuations or client version compatibility issues.

Troubleshooting steps:

  • Check the stability of the client network connection.
  • Upgrade the client to the latest Version.
  • Check the client logs to confirm the correlation between the disconnection time and the Output of thinking tags.

You can also directly Calling the Model via the DashScope API to verify whether the thinking function works normally.

Q: What to do if the model conclusion contradicts the content description when using a visual model (e.g. qwen3-vl-plus) for image safety judgment?

The safety judgment Output by the visual Model is part of the text generated by the Model and is not an independent content moderation verdict. This conclusion may vary with Model Version and region, and may also be inconsistent with the content description in the same Response, so it is not recommended to use it as the sole basis for content compliance.

If you need a stable and unified safety judgment standard, please connect to the AI safety guardrail to conduct independent content moderation on the Model's input and Output. For more information, see AI Safety Guardrail.

API Reference

Deep Think Model input Output Parameter, please seeText Generation.

Error Code

When an error occurs during execution, please seeError Codeto troubleshoot and resolve.