错误码参考
HTTP 状态码
| 状态码 | 说明 | 解决方案 |
|---|---|---|
| 200 | 成功 | - |
| 400 | 请求参数错误 | 检查请求格式 |
| 401 | 认证失败 | 检查 API Key |
| 403 | 权限不足 | 检查用户权限 |
| 404 | 资源不存在 | 检查 URL |
| 429 | 请求过于频繁 | 降低请求频率 |
| 500 | 服务器错误 | 联系客服 |
| 503 | 服务不可用 | 等待恢复 |
错误响应格式
json
{
"error": {
"message": "Invalid API key",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}错误类型
invalid_request_error
请求参数错误。
| 错误代码 | 说明 | 解决方案 |
|---|---|---|
invalid_api_key | API Key 无效 | 检查 API Key 格式 |
model_not_found | 模型不存在 | 检查模型名称 |
insufficient_quota | 余额不足 | 及时充值 |
invalid_request | 请求格式错误 | 检查请求参数 |
rate_limit_error
请求频率超限。
| 错误代码 | 说明 | 解决方案 |
|---|---|---|
rate_limit_exceeded | 请求过于频繁 | 降低请求频率 |
api_error
服务器错误。
| 错误代码 | 说明 | 解决方案 |
|---|---|---|
internal_error | 内部错误 | 等待恢复或联系客服 |
service_unavailable | 服务不可用 | 等待恢复 |
常见错误示例
401 - 认证失败
json
{
"error": {
"message": "Invalid API key",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}解决方案:
- 检查 API Key 是否正确
- 确保 Authorization 头格式正确:
Bearer sk-你的密钥
400 - 模型不存在
json
{
"error": {
"message": "Model not found",
"type": "invalid_request_error",
"code": "model_not_found"
}
}解决方案:
- 检查模型名称是否正确
- 查看 模型列表
429 - 请求过于频繁
json
{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"code": "rate_limit_exceeded"
}
}解决方案:
- 降低请求频率
- 添加请求间隔
- 使用队列控制请求速度
403 - 余额不足
json
{
"error": {
"message": "Insufficient quota",
"type": "invalid_request_error",
"code": "insufficient_quota"
}
}解决方案:
- 及时充值
- 查看 价格说明
