Skip to content

错误 ​

LLMAPI 会尽量返回 HTTP 状态码和结构化错误信息。不同协议会保留对应协议的错误格式,因此错误响应并不只有一种 JSON 形态。

通用错误格式 ​

Anthropic/OpenAI 兼容接口常见格式:

json
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "Request body is empty"
  }
}

OpenAI 图片接口常见格式:

json
{
  "error": {
    "type": "not_found_error",
    "message": "Images API is not supported for this platform"
  }
}

常见 HTTP 状态码 ​

状态码说明常见原因
400请求无效JSON 不合法、参数类型错误、平台分组不匹配。
401认证失败API Key 缺失或无效。
403权限不足余额不足、Key 类型错误、分组未启用生图能力、内容风控拦截。
404接口或能力不可用非 OpenAI 分组调用 OpenAI 同步图片接口、OpenAI 分组调用 token count。
413请求体过大请求体超过服务端配置上限。
429限流并发请求过多。
500服务错误未预期错误。
502服务商错误模型服务商返回错误。
503服务不可用无可用账号或必要服务不可用。
504超时请求执行超时。

平台限制错误 ​

非 OpenAI 分组调用 OpenAI 同步图片接口:

json
{
  "error": {
    "type": "not_found_error",
    "message": "Images API is not supported for this platform"
  }
}

OpenAI 分组调用 token count:

json
{
  "type": "error",
  "error": {
    "type": "not_found_error",
    "message": "Token counting is not supported for this platform"
  }
}

重试建议 ​

错误类型建议
400、401、403、404不要原样重试,先修正请求、认证、分组或权限。
413缩小请求体或上传资源。
429使用指数退避重试,并降低并发数。
500、502、503、504使用指数退避重试。