API request failed with status code 400: {\"object\":\"error\",\"message\":\"[{'...

2026年01月25日 17:28 状态: processing

🚨 错误信息

"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状态码为 400BadRequestError
  • 根本原因:您的API请求体(body)中包含了一个名为 thinking 的额外字段,但该API接口不接受或明确禁止了此字段的传入。

  • 具体分析:根据FastAPI/Pydantic(这是最常见的报错来源之一)的错误格式,错误位置(loc)明确指出是在请求体的 thinking 字段上。这通常是因为请求的数据模型定义中并不包含 thinking 字段,或者该字段被显式地禁用了(input: {'type': 'disabled'})。
  • 3. 解决方案


    您需要从发送给模型的API请求数据中,移除 thinking 这个字段。
    以下是以Python为例的修改方法,假设您正在使用 requests 库:

    修改前:

    python
    import requests

    payload = {
    "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)
    ``

    4. ️ 预防措施


  • 严格遵循API文档:在调用任何第三方API前,务必仔细阅读其官方接口文档,确认请求和响应的数据结构。本次错误是因为传递了文档未定义或已禁用的字段。

  • 使用SDK或强类型验证:如果DMXAPI平台提供了官方的客户端SDK,优先使用它,可以自动处理数据校验。如果自行封装请求,建议使用Pydantic等库在发送前对数据进行建模和验证,提前发现类似的多余字段问题。