Vidu
通过统一视频接口调用生数科技 Vidu。平台按传入图片数量自动选择文生视频、图生视频、首尾帧生视频或参考图生视频。
| 项 | 值 |
|---|---|
| 提交 | POST /v1/video/generations(或 POST /v1/videos) |
| 查询 | GET /v1/video/generations/{task_id}(或 GET /v1/videos/{task_id}) |
| 鉴权 | Authorization: Bearer YOUR_API_KEY |
| Content-Type | application/json |
异步流程、轮询与计费见 概述与通用流程。
支持的模型
可用模型以 模型列表 返回为准(或控制台模型价格页)。
文生视频
BASH
curl https://www.nextai-code.com/v1/video/generations \
-H "Authorization: Bearer $NEXTAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL",
"prompt": "一只橘猫在窗台上伸懒腰,阳光洒进来",
"size": "1080p",
"duration": 5,
"metadata": { "movement_amplitude": "auto", "seed": 42 }
}'
提交响应:
JSON
{
"id": "818000000000000000",
"task_id": "818000000000000000",
"object": "video",
"model": "YOUR_MODEL",
"status": "",
"progress": 0,
"created_at": 1734567890
}
任务 ID 按 概述 · 读取任务 ID 的方法读取(先 id 后 task_id)。提交响应里的 status 为空字符串,以查询结果为准。
图生视频
图片数量决定任务类型:
| 图片数 | 任务类型 |
|---|---|
| 0 | 文生视频 |
| 1 | 图生视频 |
| 2 | 首尾帧生视频(第 1 张为首帧,第 2 张为尾帧) |
| 3 张及以上 | 参考图生视频 |
BASH
# 1 张图:图生视频
curl https://www.nextai-code.com/v1/video/generations \
-H "Authorization: Bearer $NEXTAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL",
"prompt": "人物转身走向远处",
"image": "https://example.com/first.jpg"
}'
# 2 张图:首尾帧生视频
curl https://www.nextai-code.com/v1/video/generations \
-H "Authorization: Bearer $NEXTAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL",
"prompt": "从白天过渡到黑夜",
"images": ["https://example.com/start.jpg", "https://example.com/end.jpg"]
}'
image 等同于 images 只传一张。图片格式与大小要求以 Vidu 文档为准。
查询
BASH
curl https://www.nextai-code.com/v1/video/generations/818000000000000000 \
-H "Authorization: Bearer $NEXTAI_API_KEY"
data.status为SUCCESS时,成片地址在data.fail_reason(Vidu CDN 直链,直接GET下载,不要附带 API Key);封面图在data.data.creations[0].cover_url。- 用
GET /v1/videos/{task_id}查询则返回 OpenAI Video 对象,成片地址在meta_data.url。 - 失败时
data.fail_reason为 Vidu 的错误码(err_code)。
Vidu 状态与平台状态对应:
Vidu state |
平台 status |
|---|---|
created、queueing |
SUBMITTED |
processing |
IN_PROGRESS |
success |
SUCCESS |
failed |
FAILURE |
特有参数
统一字段在 Vidu 的含义
| 参数 | 说明 |
|---|---|
model |
不传时使用平台默认的 Vidu 模型,建议显式传入 |
size |
作为分辨率,如 360p、720p、1080p;默认 1080p |
duration |
时长(秒),默认 5 |
时长、分辨率的可选值因模型而异,以 Vidu 文档为准。按规格计费的模型请保证 size 能匹配价目(如 720p、1080p)。
metadata 字段
metadata 中的同名字段会覆盖上面的值。字段含义与取值以 Vidu 文档为准:
| 字段 | 类型 | 说明 |
|---|---|---|
seed |
integer | 随机种子 |
resolution |
string | 分辨率,优先于 size |
movement_amplitude |
string | 运动幅度,默认 auto |
bgm |
boolean | 是否添加背景音乐,默认 false |
payload |
string | 自定义数据,原样随任务结果返回 |
callback_url |
string | Vidu 回调地址 |
duration |
integer | 时长 |
model |
string | 覆盖模型名 |
上表以外的字段不会生效。字段类型必须与上表一致,否则返回 500 build_request_failed。
限制
| HTTP | code |
说明 |
|---|---|---|
| 400 | task_failed |
Vidu 在提交时直接判定任务失败 |
| 500 | build_request_failed |
metadata 字段类型不对 |
其它错误见 概述 · 错误。