通过 API Key 调用 Videos 系列模型生成视频。支持纯文生、首尾帧、多图参考、视频参考和音频参考。异步任务模式:先创建任务拿到任务 ID,再轮询查询结果。
在 密钥管理 创建 API Key,所有请求需在请求头携带 Bearer token:
Authorization: Bearer sk-你的密钥
https://aicodehub.net
amount 字段固定为 9.00。
支持三种模型,通过 model 字段指定:
seedance2:Seedance 2.0 标准模型,支持更多画幅与音频参考seedance2_stable:Seedance 2.0 满血模型 (暂无资源,等待后续通知)seedance2_fast:Seedance 2.0 快速模型 (暂无资源,等待后续通知)| 模型 | 时长范围 | 素材能力 | 支持比例 |
|---|---|---|---|
seedance2 | 4-15 秒 | 最多 9 张图、3 个视频、3 段音频 | 21:9、16:9、4:3、1:1、3:4、9:16 |
seedance2_stable | 4-15 秒 | 最多 4 张图、3 个视频、1 段音频 | 16:9、9:16、1:1 |
seedance2_fast | 4-15 秒 | 最多 4 张图、3 个视频、1 段音频 | 16:9、9:16、1:1 |
POST /openapi/v1/videos
创建视频生成任务。支持纯文生、首尾帧、多图/视频/音频参考。视频生成为异步处理,请保存返回的 id 用于后续查询。
携带请求头 Idempotency-Key,相同 Key 24 小时内返回同一任务,避免重复扣费。
curl --request POST \
--url https://aicodehub.net/openapi/v1/videos \
--header 'Authorization: Bearer sk-你的密钥' \
--header 'Content-Type: application/json' \
--data '{
"model": "seedance2",
"prompt": "一只可爱的小猫在草地上玩耍,电影感",
"duration": 5,
"ratio": "16:9",
"resolution": "720p"
}'
curl --request POST \
--url https://aicodehub.net/openapi/v1/videos \
--header 'Authorization: Bearer sk-你的密钥' \
--header 'Content-Type: application/json' \
--data '{
"model": "seedance2",
"prompt": "从清晨过渡到黄昏的海边延时镜头",
"duration": 8,
"first_image": "https://example.com/sea-morning.jpg",
"last_image": "https://example.com/sea-evening.jpg",
"ratio": "16:9"
}'
curl --request POST \
--url https://aicodehub.net/openapi/v1/videos \
--header 'Authorization: Bearer sk-你的密钥' \
--header 'Content-Type: application/json' \
--data '{
"model": "seedance2",
"prompt": "可爱的兔子在玩耍,背景音乐是@音频1",
"duration": 5,
"referenceImages": ["https://example.com/rabbit.png"],
"referenceAudios": ["https://example.com/bgm.mp3"],
"ratio": "9:16"
}'
curl --request POST \
--url https://aicodehub.net/openapi/v1/videos \
--header 'Authorization: Bearer sk-你的密钥' \
--header 'Content-Type: application/json' \
--data '{
"model": "seedance2",
"prompt": "角色在咖啡馆中自然对话,画面柔和,带轻微镜头推进",
"duration": 10,
"referenceImages": [
"https://example.com/character-a.jpg",
"https://example.com/character-b.jpg"
],
"referenceVideos": ["https://example.com/cafe-scene.mp4"],
"referenceAudios": ["https://example.com/dialogue-style.mp3"],
"ratio": "16:9"
}'
import requests
resp = requests.post(
"https://aicodehub.net/openapi/v1/videos",
headers={
"Authorization": "Bearer sk-你的密钥",
"Content-Type": "application/json",
},
json={
"model": "seedance2",
"prompt": "A cute kitten playing in the grass, cinematic style",
"duration": 5,
"ratio": "16:9",
"resolution": "720p",
},
)
task_id = resp.json()["id"]
HttpClient client = HttpClient.newHttpClient();
String body = """
{
"model": "seedance2",
"prompt": "A cute kitten playing in the grass, cinematic style",
"duration": 5,
"ratio": "16:9",
"resolution": "720p"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://aicodehub.net/openapi/v1/videos"))
.header("Authorization", "Bearer sk-你的密钥")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 任务唯一标识符(vtask_ 开头),用于后续查询 |
| object | string | 对象类型,固定为 video |
| created | integer | 任务创建时间戳(秒) |
| model | string | 使用的模型名称 |
| status | string | queued / processing / completed / failed |
| error | string | 错误信息,失败时返回 |
{
"id": "vtask_9f3a1c8b2e...",
"object": "video",
"created": 1774836724,
"model": "seedance2",
"status": "queued",
"error": null
}
{
"id": null,
"object": "error",
"status": "failed",
"error": "referenceAudios 最多支持 1 段,当前: 2"
}
| 字段 | 类型 | 说明 |
|---|---|---|
| model | string | 可选,默认 seedance2。可选 seedance2 / seedance2_stable / seedance2_fast |
| prompt 必填 | string | 视频生成提示词。seedance2_stable / seedance2_fast 最大 5000 字符;seedance2 不限制为 5000 |
| duration 必填 | integer | 视频时长(秒),范围 4-15,默认 5 |
| ratio | string | 输出比例,默认 16:9。seedance2 支持 21:9/16:9/4:3/1:1/3:4/9:16;seedance2_stable / seedance2_fast 仅 16:9/9:16/1:1 |
| resolution | string | 输出分辨率,默认 720p(当前仅支持 720p) |
| autoFace | boolean | 是否自动人脸处理,默认 false。仅 seedance2 生效,其他模型传递不生效 |
| 字段 | 类型 | 说明 |
|---|---|---|
| first_image | string | 首帧图片 URL,必须搭配 last_image 使用 |
| last_image | string | 尾帧图片 URL,必须搭配 first_image 使用 |
| 字段 | 类型 | 说明 |
|---|---|---|
| referenceImages | array | 参考图片 URL 列表。seedance2 最多 9 张,其他 4 张;每张 ≤ 20MB。可与视频/音频参考组合 |
| referenceVideos | array | 参考视频 URL 列表。最多 3 个;总时长 ≤ 15 秒,总大小 ≤ 200MB;单个分辨率需在 720px-2160px 之间 |
| referenceAudios | array | 参考音频 URL 列表。seedance2 最多 3 段,其他 1 段;总时长 ≤ 15 秒 |
first_image 和 last_image 必须成对使用。referenceImages、referenceVideos、referenceAudios 可单独或组合使用。referenceAudios。
| 场景 | 说明 |
|---|---|
| 纯文生视频 | 仅传 prompt、model、duration 等基础参数 |
| 首尾帧视频 | 通过 first_image 和 last_image 精确控制开头与结尾画面 |
| 多模态混合参考 | 通过 referenceImages、referenceVideos 与 referenceAudios 组合提供更强的素材约束 |
GET /openapi/v1/videos/{id}
使用创建任务返回的 id 查询任务状态与结果。
| 状态 | 说明 |
|---|---|
queued | 任务已创建并进入队列,等待处理 |
processing | 任务处理中,模型正在生成视频 |
completed | 任务完成,可通过 video_url 获取结果 |
failed | 任务失败,通过 error 查看原因 |
completed 或 failed 时停止轮询。curl --request GET \
--url https://aicodehub.net/openapi/v1/videos/vtask_9f3a1c8b2e... \
--header 'Authorization: Bearer sk-你的密钥'
import requests
resp = requests.get(
"https://aicodehub.net/openapi/v1/videos/vtask_9f3a1c8b2e...",
headers={"Authorization": "Bearer sk-你的密钥"},
)
print(resp.json())
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 任务唯一标识符 |
| object | string | 对象类型,固定为 video |
| created | integer | 任务创建时间戳(秒) |
| model | string | 使用的模型名称 |
| status | string | queued / processing / completed / failed |
| video_url | string | 生成的视频 URL,completed 时返回 |
| actualDuration | number | 视频实际输出时长(秒),completed 时返回 |
| amount | number | 本次任务计费金额(元),固定 9.00 |
| error | string | 错误信息,failed 时返回 |
{
"id": "vtask_9f3a1c8b2e...",
"object": "video",
"created": 1761635478,
"model": "seedance2",
"status": "processing",
"video_url": null,
"actualDuration": null,
"amount": 9.00,
"error": null
}
{
"id": "vtask_9f3a1c8b2e...",
"object": "video",
"created": 1761635478,
"model": "seedance2",
"status": "completed",
"video_url": "https://example.com/video.mp4",
"actualDuration": 8.0,
"amount": 9.00,
"error": null
}
{
"id": "vtask_9f3a1c8b2e...",
"object": "video",
"created": 1761635478,
"model": "seedance2",
"status": "failed",
"video_url": null,
"amount": 9.00,
"error": "Generation failed: reference video resolution is not supported"
}
id 用于后续查询。seedance2_fast。出错时返回对应 HTTP 状态码与统一结构:
{ "id": null, "object": "error", "status": "failed", "error": "insufficient balance" }
| HTTP | error | 说明 |
|---|---|---|
| 401 | invalid api key | 密钥无效或已禁用 |
| 400 | 参数错误信息 | 参数不合法(如比例不支持、缺提示词、音频数量超限) |
| 402 | insufficient balance | 账户余额不足 9 元 |
| 403 | forbidden | 无权访问该任务 |
| 404 | task not found | 任务不存在 |
| 500 | 上游/系统错误信息 | 创建失败(已自动释放冻结) |