API 错误码
API 返回的所有错误,包括 HTTP 状态码、错误码以及处理方法。错误采用 OpenAI 格式。
错误
错误采用 OpenAI 格式:{"error": {"message", "type", "code"}}。
| HTTP | code | |
|---|---|---|
| 400 | invalid_request | 请求体不是合法的 JSON,或某个字段缺失或有误。消息会指明是哪个字段。 |
| 400 | wrong_endpoint | 该模型属于其他类型:聊天模型使用 /chat/completions,图像模型使用 /images/generations,视频模型使用 /videos。 |
| 400 | size_not_available / format_not_available / too_many_images | 该图像模型不支持此尺寸或文件格式,或收到的输入图像超过其上限。消息会说明它接受什么。 |
| 400 | resolution_not_available | 该视频模型不提供此分辨率。 |
| 400 | video_not_ready | 视频尚未完成;请继续轮询 GET /videos/{id}。 |
| 400 | not_a_draft / draft_not_ready / draft_wrong_model / draft_expired | draft_id 必须是同一模型在 7 天内生成的已完成草稿。 |
| 400 | user_required | 仅限 relay 账户:每个聊天请求都必须带有 user 字段。 |
| 401 | invalid_api_key | API 密钥缺失、错误或已被吊销。 |
| 402 | insufficient_balance / key_spend_cap | 请充值余额,或提高该密钥的每日消费上限。 |
| 403 | account_inactive | 账户已被暂停。 |
| 403 | ip_not_allowed | 该密钥设置了 IP 白名单,而请求来自其他地址。 |
| 404 | model_not_found | 未知的模型 id。请查看 GET /models。 |
| 404 | video_not_found / draft_not_found | 你的账户中没有该视频或草稿。 |
| 404 | video_expired / last_frame_expired / image_expired / no_last_frame | 文件已不再保留,或请求未要求返回最后一帧。图像链接有效期 1 小时。视频链接有效期一周;未能复制到我们存储的视频,只能由模型服务商提供 24 小时。 |
| 404 | not_found | 该路径不存在。请查看 Endpoints。 |
| 405 | method_not_allowed | 该路径的 HTTP 方法错误,例如对 /chat/completions 使用 GET。 |
| 413 | request_too_large | 请求体过大。 |
| 429 | rate_limit_exceeded / concurrency_limit / model_at_capacity | 请降低请求频率,并在 Retry-After 请求头指定的时间后重试。 |
| 429 | model_rate_limit_exceeded / model_concurrency_limit | 你的账户已达到该模型的单独限制。其他模型仍可使用;请在 Retry-After 请求头指定的时间后重试。 |
| 429 | upstream_rate_limited | 模型本身已达到速率限制。请几秒后重试;本次未扣费。 |
| 429 | too_many_failed_requests | 该密钥连续发送了过多失败请求,已暂停 Retry-After 中指定的时长。请先修复你遇到的错误,然后重试。 |
| 500 | internal_error | 我们这边出现了故障。请重试;如果反复出现,请将 request_id 提供给支持。 |
| 502 | upstream_error | 模型服务商出错。可以放心重试;本次未扣费。 |
| 503 | upstream_unavailable / billing_unavailable / config_unavailable / model_not_priced / gateway_draining | 暂时性错误。请以退避方式重试。 |
| 504 | upstream_error | 模型未能及时响应。可以放心重试;本次未扣费。 |
