400 The `content[].thinking` in the thinking mode must be passed back to the API...

2026年05月27日 13:47 26.90 秒 success

错误信息

API Error: 400 The `content[].thinking` in the thinking mode must be passed back to the API. (request id: 20260527134452207962366UYvNRmGz)

AI 解决方案

🔍 错误翻译
原文:API Error: 400 The content[].thinking in the thinking mode must be passed back to the API.
译文:API 错误:400 在思考模式下,content[].thinking 字段必须被回传给 API。

🎯 原因分析
您调用的 API 处于 “thinking”(思考)模式,该模式要求客户端在后续的对话或请求中,必须将 API 上一次返回的、包含 thinking 内容的整个 content 数组项完整地、原样地发送回去,以维持对话状态或提供上下文。您当前的请求中缺少了这个必需的字段。

💡 解决方案
请检查您发起 API 请求的代码,确保在构造请求体(Request Body)时,将上一次 API 响应中包含 thinking 的整个 content 对象,原封不动地包含在请求的 content 数组中。

假设上一次 API 响应的部分内容是这样的:

{
  "content": [
    {
      "type": "thinking",
      "thinking": "让我先分析一下这个问题的本质..."
    },
    {
      "type": "text",
      "text": "根据我的分析,..."
    }
  ]
}

那么您下次的请求必须如此构造(关键部分):

{
  "messages": [
    {
      "role": "assistant",
      "content": [
        // 必须包含上一次响应的完整 content,特别是 thinking 部分
        {
          "type": "thinking",
          "thinking": "让我先分析一下这个问题的本质..."
        },
        {
          "type": "text",
          "text": "根据我的分析,..."
        }
      ]
    },
    // ... 您的新问题或指令
    {
      "role": "user",
      "content": "请基于你的分析,继续下一步。"
    }
  ],
  // ... 其他参数,如 model, stream 等
}

🛡️ 预防措施

  • 理解模式要求:在使用任何支持 thinkingchain_of_thought 或类似模式的 API 前,务必仔细阅读官方文档中关于“如何维持对话状态”或“多轮对话”的说明。

  • 使用官方/可靠客户端:如果可能,使用该 API 官方提供的 SDK 或客户端库,它们通常会自动处理状态的存储和回传,避免手动管理 thinking 这类中间状态字段的麻烦。