API request failed with status code 400: {\"object\":\"error\",\"message\":\"[{'...
🚨 错误信息
"args":{"description":"[models] Error: API request failed with status code 400: {\"object\":\"error\",\"message\":\"[{'type': 'extra_forbidden', 'loc': ('body', 'thinking'), 'msg': 'Extra inputs are not permitted', 'input': {'type': 'disabled'}}]\",\"type\":\"BadRequestError\",\"param\":null,\"code\":400}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 400: {\"object\":\"error\",\"message\":\"[{'type': 'extra_forbidden', 'loc': ('body', 'thinking'), 'msg': 'Extra inputs are not permitted', 'input': {'type': 'disabled'}}]\",\"type\":\"BadRequestError\",\"param\":null,\"code\":400}"}
🤖 AI解决方案
1. 错误翻译
text
原文:[{'type': 'extra_forbidden', 'loc': ('body', 'thinking'), 'msg': 'Extra inputs are not permitted', 'input': {'type': 'disabled'}}]
译文:[{'type': 'extra_forbidden', 'loc': ('body', 'thinking'), 'msg': '不允许额外的输入', 'input': {'type': 'disabled'}}]
2. 原因分析
这是一个HTTP状态码为 400 的 BadRequestError。
thinking 的额外字段,但该API接口不接受或明确禁止了此字段的传入。loc)明确指出是在请求体的 thinking 字段上。这通常是因为请求的数据模型定义中并不包含 thinking 字段,或者该字段被显式地禁用了(input: {'type': 'disabled'})。3. 解决方案
您需要从发送给模型的API请求数据中,移除
thinking 这个字段。以下是以Python为例的修改方法,假设您正在使用
requests 库:修改前:
python
import requestspayload = {
"model": "gpt-4",
"messages": [...],
"thinking": {...} # ⚠️ 问题所在
# ... 其他有效参数
}
response = requests.post("https://api.dmxapi.com/v1/chat/completions", json=payload)
修改后:
``python
import requests
payload = {
"model": "gpt-4",
"messages": [...],
# 移除了 thinking 字段
# ... 其他有效参数
}
response = requests.post("https://api.dmxapi.com/v1/chat/completions", json=payload)
``