文档

深度思考

深度思考让模型在生成最终回答前进行深度推理,通过内部思维链(Chain of Thought)逐步分析问题,显著提升复杂任务的准确性。适用于复杂推理、代码生成、数学计算、多步骤分析等需要深度分析的场景。

核心能力

  • 深度推理:将复杂问题拆解为多个步骤逐步分析,提升推理准确性

  • 思考过程透明:返回完整思考过程,增强可解释性

  • 灵活控制:支持开启/关闭,可根据任务复杂度按需使用

支持的模型

当前支持 mimo-v2.6-flash,mimo-v2.6-pro,mimo-v2.6-pro-ultraspeed 模型。

请求参数

在请求中设置 thinking.type 参数控制深度思考开关:enabled 开启思考或 disabled 关闭思考。

默认状态:

  • 默认开启:mimo-v2.6-flash,mimo-v2.6-pro,mimo-v2.6-pro-ultraspeed

注意事项

参数限制

在深度思考下,mimo-v2.6-flash,mimo-v2.6-pro,mimo-v2.6-pro-ultraspeed 模型不支持自定义 temperature 和 top_p 参数。即使传入该参数,实际生效值也会被模型强制采用其推荐默认值 1.0 和 0.95。

多轮对话回传要求

在 Agent 类产品的多轮会话中开启深度思考,且历史会话中存在工具调用时,后续所有 user 交互轮次中回传的 assistant 如果包含了工具调用,必须完整回传 reasoning_content 字段,否则 API 将返回 400 错误。正确回传方式请参考调用示例的“深度思考下的多轮工具调用”。

历史 reasoning_content 一旦缺失,模型上下文将不完整,可能表现出指令遵循下降,幻觉增多等现象。

受影响的 Agent 产品:

协议 受影响的 Agent 产品
OpenAI 兼容协议 TRAE、Cursor、Roo Code、Codex、GitHub Copilot CLI、Zed、AutoGen、Goose
Anthropic 兼容协议 TRAE、GitHub Copilot CLI、AutoGen、Goose、OpenClaw、OpenCode、Kilo Code

其他说明

  1. 输出长度限制:max_completion_tokens 限制的是思考内容与最终回答的总长度。若思考过程较长,留给最终回答的 token 空间会相应减少。建议设置足够的 max_completion_tokens 以避免回答被截断。

  2. 响应时间:开启深度思考会增加响应延迟,复杂任务尤为明显。建议结合 stream: true 实时查看思考过程。

调用示例

thinking 字段并非 OpenAI 标准参数。通过 OpenAI Python SDK 传入思考相关参数时,需将其置于 extra_body 中传递。

开启思考

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/v1"
)

completion = client.chat.completions.create(
    model="mimo-v2.6-pro",
    messages=[
        {
            "role": "system",
            "content": "You are MiMo, an AI assistant developed by Xiaomi. Today is date: Tuesday, December 16, 2025. Your knowledge cutoff date is December 2024."
        },
        {
            "role": "user",
            "content": "Introduce machine learning in three sentences."
        }
    ],
    max_completion_tokens=1024,
    extra_body={
        "thinking": {"type": "enabled"}
    }
)

print(completion.model_dump_json())

响应示例

{
    "id": "045bd1a4-688a-4e53-9de2-7631205e0182_5f467b0704184928936bafb270896022",
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "Machine learning is a branch of artificial intelligence that enables computers to learn from data and improve their performance over time without being explicitly programmed for every task. It works by feeding algorithms large datasets, allowing them to identify patterns, make predictions, or take actions based on what they've learned. Common applications include spam filters, recommendation systems, image recognition, and language translation, making it a powerful tool that is reshaping industries from healthcare to finance.",
                "role": "assistant",
                "tool_calls": null,
                "reasoning_content": "The user wants a concise three-sentence introduction to machine learning."
            }
        }
    ],
    "created": 1790008551,
    "model": "mimo-v2.6-pro",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 103,
        "prompt_tokens": 60,
        "total_tokens": 163,
        "completion_tokens_details": {
            "reasoning_tokens": 14
        },
        "prompt_tokens_details": {
            "cached_tokens": 0
        }
    }
}

关闭思考

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/v1"
)

completion = client.chat.completions.create(
    model="mimo-v2.6-pro",
    messages=[
        {
            "role": "system",
            "content": "You are MiMo, an AI assistant developed by Xiaomi. Today is date: Tuesday, December 16, 2025. Your knowledge cutoff date is December 2024."
        },
        {
            "role": "user",
            "content": "Write a short paragraph about the beauty of nature."
        }
    ],
    max_completion_tokens=1024,
    extra_body={
        "thinking": {"type": "disabled"}
    }
)

print(completion.model_dump_json())

响应示例

{
    "id": "ab231e1e-4d8c-4084-84bf-521959063597_b7c5e3eece0143ae98993a27e86e6df7",
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "There is an enduring, quiet magic in the world outside our windows. It’s found in the delicate, painted canvas of a sunrise bleeding across the horizon, and in the intricate architecture of a single leaf, each vein a tiny river carrying life. The power of nature's beauty lies not just in its grandest vistas—the silent, snow-capped mountains and vast, churning oceans—but also in its most intimate details: the scent of rain on dry earth, the gentle rhythm of waves on a shore, and the resilience of a wildflower pushing through a crack in the stone. It is a constant, unfolding masterpiece that whispers to the soul, a powerful reminder of a force that is at once both magnificent and profoundly soothing.",
                "role": "assistant",
                "tool_calls": null
            }
        }
    ],
    "created": 1790008574,
    "model": "mimo-v2.6-pro",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 146,
        "prompt_tokens": 64,
        "total_tokens": 210,
        "completion_tokens_details": {
            "reasoning_tokens": 0
        },
        "prompt_tokens_details": {
            "cached_tokens": 0
        }
    }
}

流式响应(开启思考)

流式响应时,思考内容与回答内容依次输出:首先通过 reasoning_content 逐步返回思考过程,思考完成后,再通过 content 逐步输出最终回答。

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/v1"
)

completion = client.chat.completions.create(
    model="mimo-v2.6-pro",
    messages=[
        {
            "role": "system",
            "content": "You are MiMo, an AI assistant developed by Xiaomi. Today is date: Tuesday, December 16, 2025. Your knowledge cutoff date is December 2024."
        },
        {
            "role": "user",
            "content": "Give me some tips for improving work efficiency."
        }
    ],
    max_completion_tokens=1024,
    stream=True,
    extra_body={
        "thinking": {"type": "enabled"}
    }
)

for chunk in completion:
    print(chunk.model_dump_json())

响应示例

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":"","role":"assistant","tool_calls":null,"reasoning_content":null},"finish_reason":null,"index":0}],"created":1790008592,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":null,"role":null,"tool_calls":null,"reasoning_content":"The user is asking"},"finish_reason":null,"index":0}],"created":1790008592,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":null,"role":null,"tool_calls":null,"reasoning_content":" for tips to"},"finish_reason":null,"index":0}],"created":1790008592,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":null,"role":null,"tool_calls":null,"reasoning_content":" improve work efficiency."},"finish_reason":null,"index":0}],"created":1790008592,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

...

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":null,"role":null,"tool_calls":null,"reasoning_content":" tips"},"finish_reason":null,"index":0}],"created":1790008593,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":null,"role":null,"tool_calls":null,"reasoning_content":"."},"finish_reason":null,"index":0}],"created":1790008593,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":"# Tips","role":null,"tool_calls":null,"reasoning_content":null},"finish_reason":null,"index":0}],"created":1790008593,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":" for Improving Work","role":null,"tool_calls":null,"reasoning_content":null},"finish_reason":null,"index":0}],"created":1790008593,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

...

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":"? ","role":null,"tool_calls":null,"reasoning_content":null},"finish_reason":null,"index":0}],"created":1790008602,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":"😊","role":null,"tool_calls":null,"reasoning_content":null},"finish_reason":null,"index":0}],"created":1790008602,"model":"mimo-v2.6-pro","object":"chat.completion.chunk"}

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[{"delta":{"content":null,"role":null,"tool_calls":null,"reasoning_content":null},"finish_reason":"stop","index":0}],"created":1790008602,"model":"mimo-v2.6-pro","object":"chat.completion.chunk","usage":null}

data: {"id":"ac06ba44-79d8-419a-830f-8e443a15b962_f3425553986841e7bd6d1799bbb89be8","choices":[],"created":1790008602,"model":"mimo-v2.6-pro","object":"chat.completion.chunk","usage":{"completion_tokens":467,"prompt_tokens":61,"total_tokens":528,"completion_tokens_details":{"reasoning_tokens":29},"prompt_tokens_details":{"cached_tokens":0}}}

data: [DONE]

思考模式下的多轮工具调用

在深度思考的多轮对话中,若涉及工具调用,回传 reasoning_content 可确保思考连续性,提升模型输出质量。

import os
import json
from openai import OpenAI

# Initialize client
client = OpenAI(
    api_key=os.environ.get("MIMO_API_KEY"),
    base_url="https://api.xiaomimimo.com/v1"
)

# Define tools
tools = [
    {
        "type": "function",
        "function": {
            "name": "get_current_weather",
            "description": "Get the current weather for a given city",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string", "description": "City name, e.g. Beijing"},
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
                },
                "required": ["location"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "get_time",
            "description": "Get the current time in a given timezone",
            "parameters": {
                "type": "object",
                "properties": {
                    "timezone": {"type": "string", "description": "Timezone, e.g. Asia/Shanghai"}
                },
                "required": ["timezone"]
            }
        }
    }
]

# Tool execution functions (replace with real API calls in production)
def get_current_weather(location: str, unit: str = "celsius") -> str:
    weather_data = {"Beijing": "Sunny 25°C", "Shanghai": "Cloudy 22°C", "Shenzhen": "Rainy 28°C"}
    return weather_data.get(location, f"Weather unknown for {location}")

def get_time(timezone: str) -> str:
    from datetime import datetime
    return datetime.now().strftime(f"%Y-%m-%d %H:%M:%S ({timezone})")

TOOL_MAP = {
    "get_current_weather": lambda **kw: get_current_weather(**kw),
    "get_time": lambda **kw: get_time(**kw)
}

def run_turn(messages, turn_num):
    """Execute a single user turn: call model, run tools in a loop until final answer."""
    request_num = 0
    while True:
        request_num += 1
        print(f"\nRequest {turn_num}-{request_num}:")

        response = client.chat.completions.create(
            model="mimo-v2.6-pro",
            messages=messages,
            tools=tools,
            extra_body={"thinking": {"type": "enabled"}}
        )

        assistant_message = response.choices[0].message
        messages.append(assistant_message)

        # Print full model response
        print(f"reasoning_content: {assistant_message.reasoning_content}")
        print(f"content: \"{assistant_message.content}\"")
        print(f"tool_calls: {assistant_message.tool_calls}")

        # If no tool calls, we have the final answer
        if not assistant_message.tool_calls:
            break

        # Execute each tool call and append results
        for tool_call in assistant_message.tool_calls:
            func_name = tool_call.function.name
            func_args = json.loads(tool_call.function.arguments)
            result = TOOL_MAP[func_name](**func_args)

            print(f"-> Tool result [{func_name}]: {result}")
            messages.append({
                "role": "tool",
                "tool_call_id": tool_call.id,
                "content": result
            })

# --- Multi-turn conversation ---
messages = []

# Turn 1
print("=== Turn 1 ===")
messages.append({"role": "user", "content": "How is the weather in Beijing today? What time is it now?"})
run_turn(messages, turn_num=1)

# Turn 2: reasoning_content from Turn 1 is already in messages via assistant_message
print("\n=== Turn 2 ===")
messages.append({"role": "user", "content": "How about Shanghai? And is it hotter or colder than Beijing?"})
run_turn(messages, turn_num=2)

示例输出

第一轮: 用户询问北京天气和当前时间。模型收到用户消息后进行思考,决定同时调用 get_current_weather 和 get_time 两个工具(Request 1-1)。客户端执行工具并将结果以 role: "tool" 消息追加到 messages 中,再次请求模型。模型结合工具结果生成最终回答(Request 1-2)。

=== Turn 1 ===

Request 1-1:
reasoning_content: The user wants both weather and time in Beijing. I can call both in parallel. Weather: get_current_weather(location: Beijing). Time: Beijing timezone is Asia/Shanghai. Call both together.
content: ""
tool_calls: [ChatCompletionMessageFunctionToolCall(id='call_01e402113df94ebfb85e3056', function=Function(arguments='{"location": "Beijing"}', name='get_current_weather'), type='function'), ChatCompletionMessageFunctionToolCall(id='call_f2bf1ab9f73842baa64e93d3', function=Function(arguments='{"timezone": "Asia/Shanghai"}', name='get_time'), type='function')]
-> Tool result [get_current_weather]: Sunny 25°C
-> Tool result [get_time]: 2026-09-22 00:38:45 (Asia/Shanghai)

Request 1-2:
reasoning_content: Present both results clearly.
content: "Here's the current information for Beijing:

- **Weather:** Sunny, 25°C (77°F) ☀️
- **Current time:** 00:38 AM, Tuesday, September 22, 2026 (Asia/Shanghai time)

It's a warm, clear day in Beijing — though it's just past midnight there right now, so the 25°C reading is more reflective of the warm night. Is there anything else you'd like to know?"
tool_calls: None

第二轮: 用户追问上海天气并与北京对比。由于第一轮的 assistant 消息(包含 reasoning_content、content、tool_calls)已通过 messages.append() 累积到对话历史中,模型能直接从上下文获取北京 25°C 的信息,只需再调用 get_current_weather 查询上海(Request 2-1),然后基于两个城市的天气数据进行对比回答(Request 2-2)。

=== Turn 2 ===

Request 2-1:
reasoning_content: Need weather and time for Shanghai, and compare to Beijing's 25°C. Call weather and time for Shanghai in parallel. The comparison only needs weather, but the previous pattern included time — the user asked "How about Shanghai?" which could mean both. I'll fetch both to be thorough, or just weather since the question focuses on comparison. I'll get both since it's ambiguous and follows the previous context.
content: ""
tool_calls: [ChatCompletionMessageFunctionToolCall(id='call_7e1e7118be8a49ef9de2e8f8', function=Function(arguments='{"location": "Shanghai"}', name='get_current_weather'), type='function'), ChatCompletionMessageFunctionToolCall(id='call_3ea278a5658443258c92b3de', function=Function(arguments='{"timezone": "Asia/Shanghai"}', name='get_time'), type='function')]
-> Tool result [get_current_weather]: Cloudy 22°C
-> Tool result [get_time]: 2026-09-22 00:38:51 (Asia/Shanghai)

Request 2-2:
reasoning_content: Shanghai: cloudy, 22°C vs Beijing sunny 25°C. Shanghai is 3°C colder. Both cities share the same timezone (Asia/Shanghai), so the time is the same.
content: "Here's the current information for Shanghai:

- **Weather:** Cloudy, 22°C (72°F) ☁️
- **Current time:** 00:38 AM, Tuesday, September 22, 2026 (Note: Shanghai and Beijing are in the same timezone, so the time is identical in both cities)

**Comparison:** Shanghai is **colder** than Beijing right now — 22°C vs. 25°C, a difference of about 3°C (5°F). Beijing is also sunny while Shanghai is cloudy. Anything else you'd like to check?"
tool_calls: None
更新时间 2026 年 10 月 20 日

Copyright©2026 Xiaomi. All Rights Reserved | Cookie Policy | Cookie Preferences

We use cookies and similar technologies of our own to ensure the proper functioning of the website, customize content according to user preferences and analyze users' interactions on the website, as well as their browsing habits. You can find more information in our Cookie Policy. Select an option or go to Cookie Settings to manage your preferences. Learn More.