错误
生成任务与资产接口的错误码和处理方式。
先检查 HTTP 状态,再根据错误码处理。message 是可读的错误说明,details 提供参数错误或关联资源等补充信息。程序应按 code 判断,并兼容未知错误码。
v2 请求错误
请求失败时,直接返回错误对象:
json
{
"code": "invalid_parameter",
"message": "Invalid parameter 'duration': must be a positive integer in seconds.",
"details": { "duration": "must be a positive integer in seconds" }
}
code、message 为字符串;details 为可选的字符串键值对象,包含字段错误或关联资源信息。参数错误通常以字段路径为键,如 duration、parts[1].image.assetId。
创建失败时,若 details 包含 generation_id,可使用该 ID 查询任务。审核错误还可能包含 asset_id 和 field。
| HTTP | code | 原因与处理 |
|---|---|---|
| 400 | invalid_request | JSON 或请求格式错误;修正请求 |
| 400 | invalid_parameter | 参数缺失、类型错误或组合不支持;检查 details |
| 400 | model_not_supported | 模型不受支持;检查 model 参数 |
| 400 | content_policy_violation | 内容未通过审核;修改提示词或图片 |
| 400 | invalid_image | 图片内容、格式或尺寸不合法;更换图片 |
| 400 | image_too_large | 图片超过大小限制;缩小图片 |
| 400 | invalid_image_url | URL 不符合公网 HTTPS 要求;修正地址 |
| 400 | image_unavailable | 图片不可访问;检查地址、权限和有效期 |
| 400 | invalid_media_url / media_unavailable | 视频或音频 URL 无效 / 源站无法下载。 |
| 400 | insufficient_credits | 可用额度不足;补充额度后提交 |
| 401 | invalid_api_key | API Key 缺失或无效;检查密钥和鉴权头 |
| 403 | organization_banned | 组织已停用 |
| 403 | permission_denied | 当前组织无权使用该模型 |
| 404 | asset_not_found | 引用的资产不存在、已删除或不属于当前组织 |
| 404 | generation_not_found | 任务不存在、已删除或不属于当前组织 |
| 429 | rate_limit_exceeded | 请求频率超限;降低频率 |
| 500 | internal_error | 内部错误;按重试建议处理 |
| 503 | service_unavailable | 服务暂不可用;按重试建议处理 |
接口不存在、方法不支持、Accept 不允许 JSON、Content-Type 不支持,分别返回 404、405、406、415,错误码均为 invalid_request。405 响应包含 Allow;401 响应包含 WWW-Authenticate: Bearer。
任务执行失败
查询失败任务仍返回 HTTP 200,此时 status 为 failed,error 字段包含失败原因:
json
{
"code": "generation_failed",
"message": "Video generation failed."
}
error.code | 说明 |
|---|---|
generation_failed | 视频生成失败 |
generation_timeout | 超出允许的处理时间 |
content_policy_violation | 输入或结果未通过审核 |
service_unavailable | 处理或审核服务暂不可用 |
insufficient_credits | 任务处理时额度不足 |
继续查询不会重新执行失败任务。如需重新生成,应处理失败原因后创建新任务。
v1 素材错误
json
{
"code": "00200",
"message": "Unknown file extension: zip",
"details": null
}
资产错误码为数字字符串,必须保留前导零。details 为可空的字符串键值对象。审核失败时,details 可能包含 assetId 和 errorCode。
| HTTP | code | 原因与处理 |
|---|---|---|
| 400 | 00003 | 检查 multipart boundary、单个 file 字段、文件名、路径 ID 或图片审核结果 |
| 400 | 00200 | 扩展名不受支持;使用支持的格式 |
| 400 | 00202 | 文件为空、无法解码,或尺寸/时长不合规;更换文件 |
| 400 | 00204 | 单个文件或完整 multipart 表单超过字节限制 |
| 401 | 00001 | 缺少或无效 API Key;检查鉴权 |
| 403 | 00002 | 组织停用或无权访问该资产 |
| 404 | 00005 | 资产不存在或已删除 |
| 429 | 00009 | 请求频率超限;降低频率 |
| 500 | 00006 | 内部处理错误 |
| 503 | 00006 | 服务暂不可用 |
不支持的 Content-Type 可能返回 415 / 00003;错误 HTTP 方法返回 400 / 00010。文件要求见上传素材。
排查问题时保留接口、请求时间、HTTP 状态、错误码及任务或资产 ID,不要记录 API Key。