Appearance
视频生成任务
创建 Seedance 视频生成任务并轮询查询结果。接口路径、请求与响应字段均与火山引擎官方一致:用 content 数组描述文本、图片、视频、音频输入。
请求地址:https://www.sky-ze.com/api/v3/contents/generations/tasks
创建任务
http
POST /api/v3/contents/generations/tasks请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | ✓ | 模型 ID,见 视频模型与计费 |
content | array | ✓ | 输入内容数组,见下方 content 结构 |
duration | integer | 视频时长(秒)。Seedance 2.0 系列 4–15;Seedance 2.5 为 4–30;传 -1 由模型自选 | |
resolution | string | 分辨率:480p / 720p / 1080p / 4k(按模型支持) | |
ratio | string | 宽高比:16:9 / 4:3 / 1:1 / 3:4 / 9:16 / 21:9 / adaptive | |
seed | integer | 随机种子 | |
generate_audio | boolean | 是否生成同步音频,默认 true | |
watermark | boolean | 是否添加水印,默认 false | |
draft | boolean | 样片模式,Seedance 2.5 支持 | |
return_last_frame | boolean | 是否返回尾帧 | |
execution_expires_after | integer | 任务过期时间(秒),范围 3600–259200 |
content 结构
| 类型 | 字段 | 说明 |
|---|---|---|
text | text | 提示词 |
image_url | image_url.url、role | 图片地址;role 可为 first_frame / last_frame / reference_image |
video_url | video_url.url、role | 视频地址;role 为 reference_video |
audio_url | audio_url.url、role | 音频地址;role 为 reference_audio |
draft_task | draft_task.id | 复用样片任务,Seedance 2.5 支持 |
image_url / video_url / audio_url 的 url 支持公网 URL,或在控制台 素材库 生成并复制的 asset://<素材ID> 引用。真人素材需本人完成活体认证后才能引用。
请求示例
bash
curl https://www.sky-ze.com/api/v3/contents/generations/tasks \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key" \
-d '{
"model": "doubao-seedance-2.0",
"content": [
{"type": "text", "text": "一只猫在海边奔跑,电影感,夕阳"},
{"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}, "role": "reference_image"}
],
"duration": 4,
"resolution": "720p",
"ratio": "16:9",
"generate_audio": false
}'python
import requests
resp = requests.post(
"https://www.sky-ze.com/api/v3/contents/generations/tasks",
headers={"Authorization": "Bearer your-api-key"},
json={
"model": "doubao-seedance-2.0",
"content": [
{"type": "text", "text": "一只猫在海边奔跑,电影感,夕阳"},
{"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}, "role": "reference_image"},
],
"duration": 4,
"resolution": "720p",
"ratio": "16:9",
"generate_audio": False,
},
)
print(resp.json())javascript
const resp = await fetch('https://www.sky-ze.com/api/v3/contents/generations/tasks', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your-api-key'
},
body: JSON.stringify({
model: 'doubao-seedance-2.0',
content: [
{ type: 'text', text: '一只猫在海边奔跑,电影感,夕阳' },
{ type: 'image_url', image_url: { url: 'https://example.com/cat.jpg' }, role: 'reference_image' }
],
duration: 4,
resolution: '720p',
ratio: '16:9',
generate_audio: false
})
})
console.log(await resp.json())响应
json
{
"id": "task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}id 为任务 ID,用于后续查询。
查询任务
http
GET /api/v3/contents/generations/tasks/{task_id}路径参数
| 参数 | 类型 | 说明 |
|---|---|---|
task_id | string | 创建任务返回的任务 ID |
请求示例
bash
curl https://www.sky-ze.com/api/v3/contents/generations/tasks/task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \
-H "Authorization: Bearer your-api-key"响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务 ID |
model | string | 实际执行的模型版本 |
status | string | 任务状态,见下方状态说明 |
content.video_url | string | 生成的视频地址,成功时返回 |
content.last_frame_url | string | 尾帧图片地址,return_last_frame=true 时返回 |
usage.completion_tokens | integer | 实际计费 token 用量 |
usage.total_tokens | integer | 实际 token 总用量 |
error | object | 失败信息,包含 code 与 message |
duration | integer | 实际视频时长(秒) |
resolution | string | 输出分辨率 |
ratio | string | 输出宽高比 |
created_at | integer | 创建时间(Unix 秒) |
updated_at | integer | 更新时间(Unix 秒) |
任务状态
| 状态 | 说明 |
|---|---|
queued | 排队中 |
running | 生成中 |
succeeded | 成功,视频地址见 content.video_url |
failed | 失败,原因见 error.message |
cancelled | 已取消 |
expired | 超时 |
成功响应示例
json
{
"id": "task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"model": "doubao-seedance-2-0-260128",
"status": "succeeded",
"content": {
"video_url": "https://example.com/result.mp4"
},
"usage": {
"completion_tokens": 108900,
"total_tokens": 108900
},
"duration": 4,
"resolution": "720p",
"ratio": "16:9",
"created_at": 1760000000,
"updated_at": 1760000300
}轮询查询
视频生成为异步任务,通常 1–3 分钟完成。建议创建任务后每 5 秒查询一次,直到状态为 succeeded、failed、cancelled 或 expired。
python
import time
import requests
base_url = "https://www.sky-ze.com"
headers = {"Authorization": "Bearer your-api-key"}
task = requests.post(
f"{base_url}/api/v3/contents/generations/tasks",
headers=headers,
json={
"model": "doubao-seedance-2.0",
"content": [{"type": "text", "text": "一只猫在海边奔跑,电影感,夕阳"}],
"duration": 4,
"resolution": "720p",
},
).json()
while True:
result = requests.get(f"{base_url}/api/v3/contents/generations/tasks/{task['id']}", headers=headers).json()
if result["status"] in ("succeeded", "failed", "cancelled", "expired"):
break
time.sleep(5)
print(result)