错误
BeeRouter 网关的每个错误都会返回结构化 JSON,带有稳定的 code 字段。请按 code 判断,而不是按面向人的 message。
错误格式
所有错误共用同一个外层结构:
{
"error": {
"code": "insufficient_credits",
"message": "Insufficient credits. Please top up and try again.",
"type": "seeai_error"
}
}
兼容 Anthropic 的 /v1/messages 接口则返回 Anthropic 自身的错误结构——顶层 type: "error",内嵌一个含 type 和 message 的 error 对象。
常见错误
| 状态码 | 错误码 | 含义 |
|---|---|---|
401 | unauthorized | 缺少、无效或已被禁用的 API Key。 |
403 | model_not_allowed | 该 API Key 无权调用所请求的模型。 |
400 | invalid_model | model 不是已知的模型 id。 |
400 | no_available_channel | 当前没有可用于该模型的上游渠道。 |
402 | insufficient_credits | 钱包余额不足以覆盖本次请求。 |
402 | subscription_quota_exceeded | 本计费周期的订阅 token 配额已用尽。 |
400 | model_pricing_missing | 该模型尚未发布销售价,暂时无法计费。 |
429 | rpm_exceeded | 超出每分钟请求数上限。 |
429 | tpm_exceeded | 超出每分钟 token 数上限。 |
429 | concurrency_exceeded | 并发请求过多。 |
502 | upstream_error | 上游服务商返回了错误。 |
500 | internal | 网关意外错误——请重试,若持续出现请联系支持。 |
限流与重试
429 响应会带 Retry-After 头(单位秒)——请等待该时长后再重试。rpm_exceeded / tpm_exceeded 分别是每分钟请求数 / token 数上限;concurrency_exceeded 表示同时进行的请求过多。
计费与定价
402 表示钱包余额不足以覆盖本次请求——请充值(insufficient_credits)或等待下个计费周期(subscription_quota_exceeded)。400 的 model_pricing_* / model_not_billable 表示该模型尚未上架销售价;请联系管理员配置并发布定价。
错误处理
用 error.code 做程序分支——它是稳定的。error.message 面向人,可能变动。429 和 502 可退避后重试;4xx 的计费或校验类错误在未修改请求前不要重试。

