Skip to main content
Models

Thinking

Solve complex tasks with step-by-step thinking

Thinking (reasoning) models reason before answering — outputting reasoning_content (Chat Completions / DashScope) or reasoning_text events (Responses API). Models support thinking in one of two modes:
  • Hybrid: toggle thinking on or off per request with enable_thinking.
  • Thinking-only: always thinks — cannot be disabled.

Enable thinking

  • OpenAI Chat Completions
  • OpenAI Responses API
  • DashScope
import os
from openai import OpenAI
client = OpenAI(api_key=os.getenv("DASHSCOPE_API_KEY"), base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1")

completion = client.chat.completions.create(
  model="qwen3.7-plus",
  messages=[{"role": "user", "content": "If 3x + 7 = 22, what is x?"}],
  extra_body={"enable_thinking": True},              # ← enable thinking
  stream=True,
)
for chunk in completion:
  if not chunk.choices:
    continue
  delta = chunk.choices[0].delta
  if hasattr(delta, "reasoning_content") and delta.reasoning_content:
    print(delta.reasoning_content, end="", flush=True)  # ← phase 1: thinking
  if hasattr(delta, "content") and delta.content:
    print(delta.content, end="", flush=True)             # ← phase 2: answer

Control thinking depth

Token budget

Use thinking_budget to cap the number of thinking tokens. If the limit is reached, the model stops thinking and generates its answer immediately. Supported by Qwen3.8, Qwen3.7, Qwen3.6, Qwen3.5, Qwen3-VL, Qwen3, GLM, and Kimi series models, and the Qwen3.8 open-source series. Chat Completions and DashScope only — not supported by the Responses API.
  • OpenAI Chat Completions
  • DashScope
extra_body={"enable_thinking": True, "thinking_budget": 500}

reasoning_effort

Use reasoning_effort to control thinking intensity by level instead of specifying a token count. Supported values and defaults vary by model. Example with qwen3.8-max (options: low, medium, xhigh; default xhigh):
  • OpenAI Chat Completions
  • DashScope
extra_body={"enable_thinking": True, "reasoning_effort": "medium"}
qwen3.8-max does not support setting reasoning_effort and thinking_budget simultaneously — doing so returns an error. When neither is set, the model uses its default.
This is not an OpenAI standard parameter. When using the Python SDK, pass it via extra_body. For supported levels, defaults, and the mapping between reasoning_effort and thinking_budget for each model, see the API Reference.

Experience deep thinking in the console

  1. Log on to the QwenCloud console.
  2. In the left-side navigation pane, choose Playground > Text models to open the model experience center.
  3. The Qwen3.7-Max model is displayed by default. You can also click the model name to select other Qwen3 series models from the dropdown list.
  4. Click Deep Thinking at the bottom of the input box to enable reasoning mode and view the model's thinking process.
  5. Switch to the Model Debugging tab and set the thinking_budget parameter in the configuration panel to control the maximum number of tokens for chain-of-thought output. Value range: 1-32768, default: 4000. To try more models, visit the model marketplace.

Prompt-level control

With enable_thinking: true, add /no_think to skip thinking for one turn. /think restores it. Last instruction wins. Supported by open-source Qwen3 hybrid models and qwen-plus-2025-04-28.

Preserve thinking in multi-turn

By default, models do not read reasoning_content from the messages array in multi-turn conversations. Set preserve_thinking to true to append the reasoning_content in assistant messages to the next input, allowing the model to reference previous reasoning. Supported models: qwen3.8-max, qwen3.7-max, qwen3.7-max-2026-06-08, qwen3.7-max-2026-05-20, qwen3.7-max-preview, qwen3.7-max-2026-05-17, qwen3.7-plus, qwen3.7-plus-2026-05-26, qwen3.6-max-preview, qwen3.6-plus, qwen3.6-plus-2026-04-02, qwen3.7-flash, qwen3.7-flash-2026-07-15.
  • OpenAI Chat Completions
  • DashScope
extra_body={"enable_thinking": True, "preserve_thinking": True}
preserve_thinking is not an OpenAI standard parameter. When using the Python SDK, pass it via extra_body.

Function calling with thinking mode

When thinking is enabled during function calling, the model reasons about which tools to call and how to use results before responding. The response includes reasoning_content before each tool call. Key points:
  • Pass enable_thinking: true alongside your tools array — no other config needed.
  • In multi-turn tool-call flows, include the assistant's reasoning_content when sending tool results back. Omitting it degrades accuracy.
  • Streaming delivers thinking tokens first, then tool call deltas. See Streaming with tool calls for the parse pattern.
  • thinking_budget works the same as in regular thinking mode.
Thinking mode is most valuable for complex tool orchestration — multi-step reasoning about which tools to call, parameter selection, and result interpretation. For simple single-tool calls, the overhead may not be worth it.

Billing

Thinking tokens are billed as output tokens. Some hybrid thinking models have different pricing for thinking mode vs. non-thinking mode. If a model in thinking mode does not produce any thinking content, it is billed at the non-thinking mode price. For model-specific thinking mode pricing, see Models.

Notes

  • Streaming required for some models: Non-streaming is supported by Qwen3.7 Max, Qwen3.7 Plus, Qwen3.6 Plus, Qwen3.5 Plus/Flash, Qwen3 Max, Qwen Plus/Flash/Turbo (commercial), and Qwen3.5 open-source models. Qwen3 open-source models and the Qwen3.8 open-source series (qwen3.8-2.4t-a95b) require streaming. Streaming is always recommended to avoid timeout risks.
  • Qwen3.8 open source series (hybrid thinking mode, thinking enabled by default): qwen3.8-2.4t-a95b
  • No audio output in thinking mode (Qwen3-Omni): Text and image inputs work normally; audio output is not available when thinking is enabled.

FAQ

Why is qwen3.7-plus slow to respond, and how do I troubleshoot it? qwen3.7-plus is a hybrid thinking model with thinking mode enabled by default. The thinking process generates a large number of reasoning tokens — more than 60% of the total output tokens in measurements — so the total latency of a single call is much higher than in non-thinking mode. The token generation speed itself is normal, at about 52 to 54 tokens/s. The longer total latency comes from the number of tokens the thinking process produces, not from a slower model or a network fault. To troubleshoot the latency:
  1. Check whether thinking mode is enabled. It is enabled by default for qwen3.7-plus. If the response returns the reasoning_content field, thinking mode is active.
  2. Review completion_tokens and reasoning_tokens in the usage statistics of the response. A high proportion of reasoning_tokens means the long total latency is expected behavior of thinking mode.
  3. If you do not need the reasoning process, set enable_thinking to false in the request to disable thinking mode. This greatly reduces output tokens and lowers total latency by 60% to 75% in measurements.
  4. If you want to keep the reasoning capability, use streaming output. You receive the first token sooner and can watch the reasoning in real time instead of waiting for the full response.
Usage statistics show the total latency of a single call, including the time spent generating reasoning tokens. This is not the generation latency of an individual token.
What do I do if a long prompt fails to generate a response or times out? If a call with a long prompt fails or times out, thinking mode (enable_thinking=true) is usually enabled. Thinking mode increases processing time, which can truncate the response or cause the request to time out when the prompt is long. Solutions:
  • Disable thinking mode: set enable_thinking to false. Processing time can drop from about 50 seconds to about 30 seconds.
  • Enable streaming output: set stream to true to avoid the timeout limit of non-streaming mode.
  • Increase the timeout: to keep thinking mode enabled, set the client timeout to 180 seconds or longer.
My third-party client disconnects after the thinking tag is output. What do I do? This is a client-side issue, not a platform restriction on exposing the thinking process. QwenCloud uses the enable_thinking parameter to toggle thinking mode, and the reasoning_content field in the response contains the full thinking process, so the model returns the thinking content as expected. The disconnection is usually caused by unstable client network conditions or client version compatibility issues. Troubleshooting steps:
  • Check the stability of the client's network connection.
  • Upgrade the client to the latest version.
  • Review the client logs to correlate the disconnection timestamp with the thinking tag output.
You can also call the model directly through the DashScope API to verify that the thinking capability works as expected.