{"error":{"message":"The reasoning_content in the thinking mode must be passed b...
🚨 错误信息
Provider returned error: {"error":{"message":"The reasoning_content in the thinking mode must be passed back to the API.","type":"invalid_request_error","param":"","code":"invalid_request_error"}}
🤖 AI解决方案
代码报错分析
#### 1. 误翻译
原文:Provider returned error: {"error":{"message":"The reasoning_content in the thinking mode must be passed back to the API.","type":"invalid_request_error","param":"","code":"invalid_request_error"}}
译文:提供商返回错误:{"error":{"message":"在思考模式中,推理内容(reasoning_content)必须回传给API。","type":"invalid_request_error","param":"","code":"invalid_request_error"}}
#### 2 原因分析
根本原因是API调用流程不完整。当您使用的模型(如深度求索等)启用了“思考”或“深度推理”模式时,API会产生中间的推理内容(reasoning_content)。此内容是一个关键的上下文状态。错误表明您的代码在后续调用中,未将上一次或本次获得的 reasoning_content 字段包含在请求体中一同发回,破坏了连续对话或推理的上下文链。
#### 3决方案
您需要在发起API请求时,将之前获得的 reasoning_content 作为上下文的一部分传入。以下是通用的修复思路:
python
伪代码示例 (以 Python requests 库为例)
import requests假设这是从上一次API响应中获取的推理内容
previous_reasoning_content = "(此处为模型之前返回的、需传递的reasoning_content字符串)"headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"model": "your-model-name",
"messages": [
# ... 您的消息历史 ...
],
"enable_thinking": True, # 假设需要开启思考模式
# ✅ 关键修复:将上一步的推理内容作为参数传回
"reasoning_content": previous_reasoning_content
}
response = requests.post("YOUR_API_ENDPOINT", headers=headers, json=payload)
核心步骤:
reasoning_content 字段。reasoning_content 键,并将上一步的值赋给它。#### 4. 预防措施
检查响应与请求:建立日志,完整记录每次API的响应体(特别是
reasoning_content等新字段)和发送的请求体,便于调试上下文传递是否正确。reasoning_content、conversation_id等状态字段的传递。