Qwen4-Max 傳回可顯示的思維鏈摘要和完整思維鏈的密文,用於多轮對話中恢復歷史思考。
適用模型:
默认傳回完整思維鏈。開啟本功能后,原始思維鏈不再以明文傳回,改為傳回摘要與完整密文。摘要用於顯示,密文用於恢復歷史思考。
摘要與加密同時開啟。未產生思考或加密失敗時,密文可能缺失;摘要可能缺失或不完整,接口仍不返回原始思維鏈。
每輪請求都需開啓本功能,並原樣回傳歷史密文,以恢復對應的歷史思考。
文本和多模态輸入使用相同參數;密文只保存思維鏈,圖片、影片等歷史輸入仍需保留。多段思考或工具呼叫時,每段密文随所属 assistant 訊息分別保存。
Chat Completions 和 DashScope 需開啟
以下示例使用新加坡地域。將
Chat Completions 串流顺序:
回傳歷史時保留完整密文;摘要可省略,Responses 的
本功能不額外收费,按模型原有輸入、輸出 Token 計費規則計費。
qwen4-max。
工作原理
默认傳回完整思維鏈。開啟本功能后,原始思維鏈不再以明文傳回,改為傳回摘要與完整密文。摘要用於顯示,密文用於恢復歷史思考。
摘要與加密同時開啟。未產生思考或加密失敗時,密文可能缺失;摘要可能缺失或不完整,接口仍不返回原始思維鏈。
每輪請求都需開啓本功能,並原樣回傳歷史密文,以恢復對應的歷史思考。
文本和多模态輸入使用相同參數;密文只保存思維鏈,圖片、影片等歷史輸入仍需保留。多段思考或工具呼叫時,每段密文随所属 assistant 訊息分別保存。
Chat Completions 和 DashScope 需開啟 enable_thinking=true;回传密文續推時設定 preserve_thinking=true。Responses 和 Anthropic Messages 使用各自的思考參數。
開啟方式
以下示例使用新加坡地域。將 WorkspaceId 替換為真實業務空間 ID,並設定 DASHSCOPE_API_KEY。
| 接口 | 開啟參數 | 摘要欄位 | 密文欄位 |
|---|---|---|---|
| Chat Completions | thinking_display="summarized" | choices[i].message.reasoning_content | choices[i].message.encrypted_content |
| Responses | reasoning.summary="auto" | summary[].text | encrypted_content |
| Anthropic Messages | thinking.display="summarized" | thinking | signature |
| DashScope | parameters.thinking_display="summarized" | output.choices[i].message.reasoning_content | output.choices[i].message.encrypted_content |
- Chat Completions
- Responses
- Anthropic Messages
- DashScope
curl
傳回與串流處理
Chat Completions 串流顺序:choices[i].delta.reasoning_content 摘要增量 → 獨立 encrypted_content 密文影格 → 正文或工具呼叫 → 结束。非串流欄位位于 choices[i].message。密文一次傳回,不要因文本為空而過濾密文影格,也不要為密文單獨创建 assistant 訊息。
Responses 的 reasoning item 包含 summary(summary_text 元素)和 encrypted_content。摘要按文本增量傳回,密文在 reasoning item 完成事件及最終 response 中傳回;可从完成快照补齐密文,不要重复追加摘要。
Anthropic Messages 的 thinking block 包含 thinking 摘要和 signature 密文。串流先傳回 thinking_delta,再傳回完整 signature_delta,關閉 thinking block 后傳回正文或工具呼叫;未产生思考或加密失败時 signature 可能為空字符串。
DashScope 欄位位于 output.choices[i].message,串流顺序與 Chat Completions 一致。密文放在 encrypted_content,不能放进 content[].text。中間影格的 finish_reason 為字符串 "null",最終為 "stop";usage 為累計值,不要重复累加。
多轮對話
回傳歷史時保留完整密文;摘要可省略,Responses 的 summary 可設爲空數組。
- Chat Completions
- Responses
- Anthropic Messages
- DashScope
OpenAI Python SDK 的非標準參數
enable_thinking、thinking_display、preserve_thinking 通過 extra_body 傳入。Python