错误码
API 使用标准 HTTP 状态码,并以统一的响应格式返回详细的错误信息。
| 状态码 | 含义 |
|---|
| 200 | 成功 |
| 400 | 请求错误 — 参数无效 |
| 401 | 未授权 — 令牌无效或已过期 |
| 402 | 需要付款 — 配额不足 |
| 403 | 禁止访问 — 无权访问该资源 |
| 404 | 未找到 — 资源不存在 |
| 413 | 请求体过大 — 请求体超出大小限制 |
| 429 | 请求过多 — 超出速率限制 |
| 500 | 服务器内部错误 |
| 502 | 网关错误 — 上游 AI 服务不可用 |
| 503 | 服务不可用 — 暂时过载 |
所有错误返回统一的 JSON 结构:
{
"error": {
"code": 400,
"message": "Invalid prompt parameter",
"type": "invalid_request_error",
"param": "prompt",
"fallback_suggestion": "provide a valid prompt"
}
}
| 字段 | 类型 | 描述 |
|---|
error.code | integer | HTTP 错误状态码 |
error.message | string | 可读的错误描述 |
error.type | string | 错误类型分类(见下表) |
error.param | string | 相关的参数名称(如适用) |
error.fallback_suggestion | string | 建议的解决操作 |
| 类型 | HTTP 状态码 | 描述 |
|---|
invalid_request_error | 400 | 请求参数无效或缺失 |
authentication_error | 401 | API 令牌无效或已过期 |
insufficient_quota_error | 402 | 账户积分不足。前往充值 |
permission_error | 403 | 无权访问该模型或资源 |
not_found_error | 404 | 请求的资源(模型、任务)未找到 |
request_too_large_error | 413 | 请求体超出大小限制 |
rate_limit_error | 429 | 请求过多 — 在建议的时间间隔后重试 |
internal_server_error | 500 | 服务器内部错误 — 请稍后重试 |
upstream_error | 502 | 上游 AI 服务不可用 — 尝试使用其他模型 |
service_unavailable_error | 503 | 服务暂时不可用 — 30 秒后重试 |
import requests
response = requests.post(
"https://api.evolink.ai/v1/videos/generations",
headers=headers,
json=payload
)
if response.status_code == 200:
task = response.json()
print(f"Task created: {task['id']}")
elif response.status_code == 429:
# Rate limited — back off and retry
print("Rate limited. Retrying...")
elif response.status_code == 402:
print("Insufficient credits. Please top up at https://evolink.ai/dashboard/billing")
else:
error = response.json().get("error", {})
print(f"Error [{error.get('type')}]: {error.get('message')}")
if error.get("fallback_suggestion"):
print(f"Suggestion: {error.get('fallback_suggestion')}")
- 视频生成失败不会从您的账户扣费
- 通过 异步任务 查看任务状态以了解失败详情
- 大多数错误可以通过调整参数并重试来解决