本文覆盖 AI API 最常见的报错,按错误码从小到大排列,每条给出原因与处理办法。 排查前请先记住三件事:
- 失败请求不计费;
- 提供 Request ID 能大幅加快客服定位;
- 报错常来自客户端消息构造,未必是平台故障。
| 错误 | 常见原因 | 一句话处理 |
|---|---|---|
| 400 | 消息序列不合法 / 参数不支持 | 检查 tool_calls 链、reasoning_content 回传、不支持的字段 |
| 402 | 账户余额不足 | 充值 |
| 403 | 权限或 WAF 拦截 | 换网络 / 补余额 / 检查 Key 权限 |
| 404 | 模型名错误 | 用正确的 Model ID |
| 429 | 容量过载 或 Key 预算超限 | 配置 fallback + 重试;或提高 Key 预算 |
| 500 | 上游异常 | 重试;仍失败报 Request ID |
| 503 | 集群过载 | 换模型/重试,见下 |
Content block is not a thinking block | thinking 兼容性 | 降级或换模型 |
No deployments available | 节点冷却 | 稍后重试 |
budget_exceeded | Key 预算超限 | 提高 Key 预算上限 |
400 是最常见的报错,且绝大多数属于请求内容问题。
错误信息:
[invalid_request_error] An assistant message with 'tool_calls' must be followed
by tool messages responding to each 'tool_call_id'.
(insufficient tool messages following tool_calls message)
含义:你发送了带 tool_calls 的 assistant 消息,但后面没有为每个 tool_call_id 附上对应的 role=tool 消息。
正确处理:
messages: [
{ "role": "user", "content": "请查询订单 123 状态" },
{ "role": "assistant", "content": null,
"tool_calls": [ { "id": "call_1", "type": "function",
"function": { "name": "get_order", "arguments": "{...}" } } ] },
{ "role": "tool", "tool_call_id": "call_1", "content": "{\"status\":\"已发货\"}" }
]
排查顺序:
错误信息:
[invalid_request_error] The reasoning_content in the thinking mode must be passed back to the API.
处理:把上一轮返回的 reasoning_content 原样回传(多数 SDK 会自动处理;手动拼装时需保留)。
Extra inputs are not permitted —— 常见于传了后端不支持的字段,如:
tool_stream(不支持,true/false 都会 400)thinking: {"type":"enabled"}(会 400)reasoning_effort: "minimal"(改用 none)合法的 reasoning_effort:none / low / medium / high / xhigh / max / adaptive
{"code":400,"message":"Bad Request","type":"invalid_request_error"} (如 model=kimi-k3)
处理:核对 Model ID 拼写(如 glm-5.3[1m] 这类带后缀的写法可能不被识别)。
含义:账户余额不足。
处理:
案例:客户端显示
HTTP 402 账户余额不足,但后台有余额且限额未超 —— 多为 Key 维度预算或计费口径差异,需客服核对。
常见两类原因:
另有控制台操作返回 403(如停用某个 API Key);属权限/界面问题,需客服处理。
模型调用失败。未存在命名模型
There's an issue with the selected model (glm-5.3[1m]). It may not exist or you may not have access to it.
处理:
GET /v1/models 核对可用列表;[1m] 等后缀。429 有两个完全不同的来源,先区分再处理。
budget_exceeded){"error": {"message": "... budget_exceeded ...", "code": 429}}
特征:
max_budget 到了。处理:控制台 → AI → API 管理 → 找到该 Key → 提高 Key 级 max budget,使其高于账户余额。
HTTP 429
{"error":{"code":429,"message":"No deployments available"}}
特征:
处理:
Agent(自动避开不健康节点);glm-5.3 / kimi-k2.6);背景:当前 429/503 主要来自后端算力容量过载,属平台侧容量问题。
含义:上游异常。
HTTP 500
{"error":{"message":"upstream error: do request failed"}}
处理:
注意:日志显示"成功"但客户端报错时,以 Request ID 为准,让客服查明细。
HTTP 503
{"error":{"code":503,"message":"Service Overload"}}
含义:后端部署过载(容量问题)。
处理:
GLM-5.3 / Kimi K2.6 算力更充裕);高峰期算力紧张时,部分热门模型会出现算力短缺、限流与 429,建议配置 fallback 与退避重试。
API Error: Content block is not a thinking block
背景:部分客户端(Claude Code 等)会把模型的思考块按 Anthropic 格式解析;当平台返回内容不是 thinking block 时即报此错。
相关兼容性问题:
| 现象 | 说明 |
|---|---|
thinking: {"type":"disabled"} 返回 200 但仍下发 reasoning_content | 思考未被真正关闭 |
tool_stream 传值即 400 | 字段不支持 |
Responses API 报 missing field 'summary' | 响应格式兼容性不足 |
| 无法指定思考程度 / 关闭思考仍深度思考 | 当前后端为思考型模型,最低只到 low |
处理建议:
reasoning_effort: "none"(若被拒则用 low);thinking: {"clear_thinking": false}(不带 type);现象:某次请求消耗远超预期,或费用异常偏高。
常见原因(属客户端行为,非平台故障):
kimi-k3 单次提交约 90 万输入 token,按 token 计费导致单次约 1.49 USD。处理:
max_budget;申诉:如确有异常扣费,提供 Request ID 给客服核对明细。
为加快定位,请在工单里附上:
| 项目 | 说明 |
|---|---|
| 时间 | 含时区,例如 2026-08-30 21:15 (UTC+8) |
| Request ID | 最关键,日志里那一长串 |
| 错误摘要 | 保留 HTTP code、必要的 error.code / error.message、trace/Request ID、时间、模型名和按需网络信息;删除 Authorization、API Key、Token、Cookie、密码、私钥、登录验证码及无关个人/业务数据 |
| 模型 ID | 例如 deepseek-v4.1-flash |
| 客户端 | OpenCode / Claude Code / 自研程序 + 版本 |
| Key 别名 | 便于定位是哪把 Key |
不要把完整 Key 贴在工单里;提供 别名即可。若已泄露请立即重建。
AI API 接入指南模型列表、能力与可用性说明限流、并发与配额规则计费与用量:token 口径、缓存、扣费申诉