Long Video 长视频
Long Video 根据一条提示词生成 4–180 秒连续成片。你可以选择 HappyHorse 或 Seedance 作为生成 provider,并通过现有任务查询接口或回调接收异步结果。
模型
| 模型名称 | 说明 |
|---|---|
long-video | 支持全局参考图的长视频生成 |
定价
成功任务按请求时长、分辨率和 provider 收费。
| Provider | 分辨率 | Credits/秒 |
|---|---|---|
| HappyHorse | 720p | 27.5 |
| HappyHorse | 1080p | 47.2 |
| Seedance | 480p | 18 |
| Seedance | 720p | 38 |
| Seedance | 1080p | 95 |
创建任务时预扣 credits;生成失败会全额退款。
创建任务
POST https://api.aivideoapi.ai/v1/videos/generations
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 固定为 long-video |
input | object | 是 | 视频生成参数 |
callback_url | string | 否 | 接收平台标准的任务完成或失败回调 |
Input 参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
prompt | string | 是 | 视频描述,1–2500 字符 |
duration | integer | 是 | 输出时长,4–180 秒 |
provider | string | 否 | happyhorse(默认)或 seedance |
resolution | string | 否 | 默认 720p;HappyHorse 支持 720p/1080p,Seedance 支持 480p/720p/1080p |
aspect_ratio | string | 否 | 默认 16:9,支持 16:9、9:16、1:1、4:3、3:4 |
continuity_mode | string | 否 | consistent(默认)或 seamless |
style | string | 否 | 风格说明,最长 500 字符 |
image_urls | string[] | 否 | 最多 5 张全局参考图,仅能用于 consistent 模式 |
native_audio_continuity | boolean | 否 | Seedance 专用,默认 false |
seed | integer | 否 | 0–2147483647,默认 42 |
示例
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "long-video",
"callback_url": "https://your-server.com/webhook",
"input": {
"prompt": "一名旅行者沿着河流从群山来到海边城市",
"duration": 60,
"provider": "seedance",
"resolution": "720p",
"aspect_ratio": "16:9",
"continuity_mode": "consistent",
"image_urls": ["https://example.com/character.jpg"],
"native_audio_continuity": true
}
}'
响应
{
"code": 200,
"msg": "success",
"data": {
"taskId": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24"
}
}
查询任务
curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
-H "Authorization: Bearer sk-your-api-key"
任务状态从 pending 变为 processing,最终进入 completed 或 failed。成功后最终视频位于 output.urls。
常见错误码
请求失败时,API 返回 JSON 格式的错误响应:
{
"error": {
"code": "insufficient_credits",
"message": "Your credit balance is too low. Please top up.",
"type": "billing_error"
}
}
错误码一览
| HTTP 状态码 | 错误码 | 类型 | 说明 |
|---|---|---|---|
| 400 | invalid_request | invalid_request_error | 缺少必填参数或参数无效 |
| 401 | invalid_api_key | authentication_error | API Key 无效、已禁用或已删除 |
| 402 | insufficient_credits | billing_error | 积分余额不足,请充值 |
| 403 | ip_not_allowed | permission_error | 请求 IP 不在 Key 的白名单中 |
| 404 | model_not_found | invalid_request_error | 模型不存在或已停用 |
| 404 | task_not_found | invalid_request_error | 任务 ID 不存在 |
| 429 | rate_limit_exceeded | rate_limit_error | 请求过于频繁,请降低频率 |
| 429 | spend_limit_exceeded | billing_error | 达到 Key 的消费限额(每小时/每天/总量) |
| 500 | internal_error | api_error | 服务器内部错误 |
| 503 | upstream_error | upstream_error | 上游 AI 服务返回错误 |
常见场景
invalid_request (400)
缺少必填字段或参数格式错误时返回。
{
"error": {
"code": "invalid_request",
"message": "'model' is required.",
"type": "invalid_request_error"
}
}
insufficient_credits (402)
积分不足。可通过 GET /v1/credits 查询余额,前往 Dashboard > Billing 充值。
invalid_api_key (401)
可能原因:
- Key 不以
sk-开头 - Key 已被禁用或删除
- 用户账户已被封禁
upstream_error (503)
上游 AI 服务返回错误,可能原因:
- 输入内容包含敏感或违规信息
- 上游服务暂时不可用
- 请求参数不被上游支持
因上游错误导致任务失败时,预扣积分会自动退还。