API 平台

错误码

同步错误采用 error.message/type/param/code 结构;异步失败采用内部标准错误结构,需要单独处理。

同步错误结构

JSON
{
  "error": {
    "message": "billing error",
    "type": "billing_error",
    "param": null,
    "code": "insufficient_credits"
  }
}
HTTPtype说明
400invalid_request_error请求参数错误
401authentication_error鉴权失败,框架支持
402billing_error计费或余额问题
403permission_error无权限、安全拦截、当前 AGW API Key 失败常见落点
404not_found_error资源不存在
409conflict_error资源冲突
429rate_limit_error限流或并发超限
500/502/503/504internal / upstream / service / timeout系统、下游、服务不可用或超时

常见 code

code说明
missing_required_field缺少必填字段
invalid_field_value字段值不合法
unsupported_response_format不支持的输出格式
invalid_url / url_not_allowedURL 格式不合法或不允许访问
insufficient_credits余额不足
rate_limit_exceeded / concurrency_limit_exceeded请求频率或并发超限
file_not_found / voice_not_found / task_not_found资源不存在
safety_guardrail_blocked安全检测拦截

异步失败结构

异步任务失败时 statusFAILEDerror 是内部标准错误结构,与同步错误结构不同。

JSON
{
  "id": "task-xxx",
  "object": "audio.speech",
  "status": "FAILED",
  "error": {
    "error_code": 16001,
    "error_msg": "billing error",
    "internal_error_code": 109111005,
    "internal_error_msg": "insufficient credits"
  }
}