CokeAPI
通用接口

错误码

CokeAPI 全量错误码表,与 HTTP 状态码、OpenAI 风格 error.type 的映射。

所有失败响应统一格式:

{
  "error": {
    "type": "<错误类型>",
    "code": <业务码>,
    "message": "<可展示文案>",
    "trace_id": "<排障 ID>"
  }
}

code 字段:前 3 位与 HTTP 状态码一致,后 3 位为子码

400xxx · 参数 / 业务前置错误

codetypemessageHTTP
400101invalid_param参数错误400
400102bad_request请求格式不正确400
400103body_too_large请求体过大413
400401insufficient_points点数不足400

401xxx · 鉴权

codetypemessageHTTP
401101unauthorized未登录401
401102token_expired登录已过期401
401103token_invalid登录凭证无效401
401104api_key_invalidAPI Key 无效401

403xxx · 权限

codetypemessageHTTP
403101forbidden权限不足403
403102ip_not_allowedIP 不在白名单403

429xxx · 限流

codetypemessageHTTP
429101rate_limit_exceeded操作过于频繁429
429301gen_rate_limited创作频次超限429
429302daily_quota_exceeded每日调用配额已用尽429

502xxx · 上游

codetypemessageHTTP
502201upstream_unavailableGPT 服务暂不可用502
502202upstream_unavailableGROK 服务暂不可用502
502203no_available_account暂无可用账号502

5xx · 系统

codetypemessageHTTP
500001internal系统繁忙500
500002db_error数据库错误500
500003cache_error缓存错误500

重试建议

  • 429xxx:按 Retry-After 头退避重试。
  • 502xxx:指数退避,最多 3 次 (CokeAPI 已在内部做账号池切换,客户端不要短时间内大量重试)。
  • 4xx 业务错误:不要重试,先看 message 修参数。
  • 报错时把 trace_id 贴给我们,可在控制台「请求日志」直接搜到全链路。

On this page