


















API Error: 400 {"error":{"message":"The content[].thinking in the thinking mode must be passed back to the API.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}
当前claude版本: 2.1.118 (Claude Code)
这个错误是 Claude Code 在使用 DeepSeek V4 模型时因思考模式(thinking mode)的机制引发的。
DeepSeek V4 默认启用思考模式(thinking mode),模型在输出最终答案前会先输出一段思维链(Chain-of-Thought),通过 reasoning_content 参数返回。
API 对 Tool Call(工具调用)轮次(即 Agent 多轮交互场景)的推理连续性有严格校验,官方文档明确指出:
"在两个 user 消息之间,如果模型进行了工具调用,则中间 assistant 的
reasoning_content需参与上下文拼接,在后续所有 user 交互轮次中必须回传给 API。"
https://api-docs.deepseek.com/zh-cn/guides/thinking_mode
同一对话中切换过不同厂商的模型
会话前半段使用了 OpenAI、Anthropic 或其他非 DeepSeek 模型,切回 DeepSeek V4 后,Claude Code 尝试将之前的对话历史(不含 reasoning_content)发给 DeepSeek,而 DeepSeek 严格校验发现缺少应有的 reasoning_content,便报出 The content[].thinking in the thinking mode must be passed back to the API 错误。
中间层(API 网关、代理、中转服务)未能完整透传 reasoning_content
若通过 API 网关、代理或中转服务调用 DeepSeek,这些中间层可能丢失或未正确处理 reasoning_content 字段,导致 API 收到的消息不完整。
这种情况常见于在 Claude Code 中通过第三方代理接入 DeepSeek 的场景——代理协议转换时如果漏掉了 reasoning_content 字段,就会触发校验失败。
对话历史中缺失必要的 reasoning_content 信息
在多轮 Agent 对话中,新的请求必须携带完整的消息历史,其中包含此前所有轮次返回的 reasoning_content。如果 Claude Code 在拼接上下文时遗漏了该字段,也会触发该错误。
如果对话中途出现该错误,最快捷的解决方式是直接重启 Claude Code 或开启一个全新的对话会话,不要复用之前已损坏的会话上下文。
DeepSeek V4 对工具调用轮次有严格的推理连续性要求,混用其他模型会破坏这一结构。建议:
开发者社区反馈新版 Claude Code 对 DeepSeek 思考模式的兼容性有所改善。建议更新至最新版本:
同时检查 Claude Code 的版本:
claude --version
reasoning_content如果你的请求经过了代理网关(如 SuCloud、SiliconFlow 等),请向服务提供方确认:
reasoning_content 字段是否在响应和后续请求中被正确保留和透传社区也曾报告类似问题——群友反馈用 API 网关中转时经常遇到该错误,改用官方直连后问题消失。建议尽量直接使用 DeepSeek 官方 API:
ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
DeepSeek 要求每次请求携带完整的对话历史,且包含所有 assistant 消息中的 reasoning_content 字段。如果使用自定义代理或网关,应确保:
reasoning_contentcontent 一并塞入 messages[-2](即上一条 assistant 消息)如果上述方案均无效,可在 Claude Code 的配置中关闭思考模式,使其按非思考模式运行。
不过需要注意的是:
effort 会自动设置为 max此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。