Skip to main content

Thinking summary and encryption

Qwen4-Max returns a displayable thinking summary and the encrypted full thinking content to restore reasoning history in multi-turn conversations.

Supported model: qwen4-max.

How it works

Full thinking is returned by default. When enabled, raw thinking is no longer returned in plaintext: the model returns a summary for display and the encrypted full thinking for restoring reasoning history. Summaries and ciphertext are enabled together. Ciphertext may be absent if no reasoning is generated or encryption fails. Summaries may be missing or incomplete; raw reasoning remains unavailable. Enable this feature in every request and replay historical ciphertext unchanged to restore the corresponding reasoning. Text and multimodal input use the same parameters. Encryption stores only thinking, so retain historical images, videos, and other inputs. Store each encrypted thinking segment with its assistant message, including tool-call turns. Enable enable_thinking=true for Chat Completions and DashScope, and use preserve_thinking=true to continue with encrypted history. Responses and Anthropic Messages use their own thinking parameters.

Enable the feature

These examples use Singapore. Replace WorkspaceId with your workspace ID and set DASHSCOPE_API_KEY.
APIEnabling parameterSummary fieldEncrypted field
Chat Completionsthinking_display="summarized"choices[i].message.reasoning_contentchoices[i].message.encrypted_content
Responsesreasoning.summary="auto"summary[].textencrypted_content
Anthropic Messagesthinking.display="summarized"thinkingsignature
DashScopeparameters.thinking_display="summarized"output.choices[i].message.reasoning_contentoutput.choices[i].message.encrypted_content
  • Chat Completions
  • Responses
  • Anthropic Messages
  • DashScope
curl
curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "qwen4-max",
  "messages": [
    {
      "role": "user",
      "content": "Calculate 17×23."
    }
  ],
  "enable_thinking": true,
  "thinking_display": "summarized",
  "preserve_thinking": true
}'

Responses and streaming

Chat Completions streams summary deltas in choices[i].delta.reasoning_content, then a separate complete encrypted_content frame, then text or tool calls, and then completion. Non-streaming fields are in choices[i].message. Do not discard an encrypted frame because its text is empty or create a separate assistant message for it. A Responses reasoning item contains summary (with summary_text elements) and encrypted_content. Summary text arrives incrementally; encrypted content arrives in the reasoning item completion event and final response. Use the completed snapshot to recover encrypted content without appending the summary twice. An Anthropic Messages thinking block contains a thinking summary and an encrypted signature. Streaming emits thinking_delta first, then a complete signature_delta; text or tool calls follow after the thinking block closes. The signature may be empty if encryption fails or no thinking is generated. DashScope fields are in output.choices[i].message and follow the Chat Completions streaming order. Put ciphertext in encrypted_content, not content[].text. Intermediate finish_reason is the string "null", and the final value is "stop". Streaming usage is cumulative; do not add it repeatedly.

Multi-turn conversations

Retain complete ciphertext when replaying history. Summaries can be omitted; the Responses summary array can be empty.
  • Chat Completions
  • Responses
  • Anthropic Messages
  • DashScope
Pass the non-standard OpenAI Python SDK parameters enable_thinking, thinking_display, and preserve_thinking through extra_body.
Python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["DASHSCOPE_API_KEY"],
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
questions = [
    "Calculate 17×23.",
    "Now add 9."
]
history = []

for turn, question in enumerate(questions, start=1):
    history.append({"role": "user", "content": question})
    response = client.chat.completions.create(
        model="qwen4-max",
        messages=history,
        max_tokens=8192,
        stream=False,
        extra_body={
            "enable_thinking": True,
            "thinking_display": "summarized",
            "preserve_thinking": True,
        },
    )
    assistant_message = response.choices[0].message.model_dump(exclude_none=True)
    history.append(assistant_message)
    print(f"Turn {turn}")
    print("Summary:", assistant_message.get("reasoning_content", ""))
    print("Answer:", assistant_message["content"])

Billing

This feature has no additional charge. The model’s existing input and output token billing rules apply.