API 手册
Seedance 视频生成
Seedance 文生视频、图生视频、首尾帧和多素材参考接口
Seedance API 使用统一 /v1/videos 视频任务接口,支持文生视频、图生视频、首尾帧和多素材参考。提交任务后通过轮询获取结果。
接口概览
| 能力 | 方法 | 路径 |
|---|---|---|
| 提交任务 | POST | /v1/videos |
| 查询任务 | GET | /v1/videos/{task_id} |
所有接口都使用:
Authorization: Bearer $API_KEY可用模型
| 模型 | 说明 | 计费 | 默认分辨率 |
|---|---|---|---|
seedance-2-official | 标准版 | 按秒 | 480p |
seedance-2-official2-fast | 快速版 | 按秒 | 720p |
seedance-2-beta-face | 标准版,支持人脸素材 | 按次 | 480p |
seedance-2-fast-beta-face | 快速版,支持人脸素材 | 按次 | 720p |
所有模型支持 21:9、16:9、4:3、1:1、3:4、9:16,时长范围为 4 到 15 秒。
生成模式
| mode | 场景 | 素材 |
|---|---|---|
text_to_video | 文生视频 | 不传素材 |
image_to_video | 图生视频 | 1 张图片 |
first_last_frame | 首尾帧 | 2 张图片 |
multi_ref | 多素材参考 | 多张图片,或图片、视频、音频混合 |
如果不传 mode,系统会根据素材自动判断:无素材为文生视频,1 张图为图生视频,2 张图为首尾帧,3 张及以上或包含视频/音频时为多素材参考。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | Seedance 模型名称 |
prompt | string | 是 | 提示词,1 到 2500 字符 |
mode | string | 否 | 不传时自动判断 |
ratio | string | 否 | 画面比例,默认 16:9 |
duration | number | 否 | 时长,4 到 15 秒,默认 5 |
resolution | string | 否 | 480p、720p、1080p |
image_url | string | 否 | 单图 URL |
image_urls | string[] | 否 | 多图 URL |
video_urls | string[] | 否 | 视频参考 URL,最多 3 个 |
audio_urls | string[] | 否 | 音频参考 URL,最多 3 个 |
webhook_url | string | 否 | 任务完成后的回调 URL |
auto_review | boolean | 否 | 自动白名单校验,默认 true |
提交任务
curl https://cdn.12ai.org/v1/videos \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2-official",
"mode": "text_to_video",
"prompt": "一只橘猫在花园里追逐蝴蝶,慢动作,电影级画质",
"duration": 5,
"resolution": "480p",
"ratio": "16:9"
}'curl https://cdn.12ai.org/v1/videos \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2-official2-fast",
"mode": "image_to_video",
"prompt": "让图片中的人物自然转身,镜头缓慢推进",
"image_url": "https://example.com/start.jpg",
"duration": 5,
"ratio": "16:9"
}'curl https://cdn.12ai.org/v1/videos \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2-official2-fast",
"mode": "first_last_frame",
"prompt": "从第一张图自然过渡到第二张图,动作平滑",
"image_urls": [
"https://example.com/first.jpg",
"https://example.com/last.jpg"
],
"duration": 6,
"ratio": "16:9"
}'curl https://cdn.12ai.org/v1/videos \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2-fast-beta-face",
"mode": "multi_ref",
"prompt": "参考图片中的人物和视频中的动作,生成一段自然的产品展示视频",
"image_urls": [
"https://example.com/person.jpg",
"https://example.com/product.jpg"
],
"video_urls": [
"https://example.com/motion.mp4"
],
"duration": 8,
"ratio": "16:9"
}'提交响应
{
"id": "task_xxx",
"status": "queued",
"model": "seedance-2-official",
"created_at": 1760000000
}查询任务
curl https://cdn.12ai.org/v1/videos/task_xxx \
-H "Authorization: Bearer $API_KEY"状态说明
| status | 说明 |
|---|---|
queued | 已排队 |
processing | 生成中 |
completed | 已完成 |
failed | 失败,查看 error.message |
完成响应
{
"id": "task_xxx",
"status": "completed",
"progress": 100,
"model": "seedance-2-official",
"data": [
{
"url": "https://img.12ai.org/videos/task_xxx.mp4"
}
]
}Python 轮询示例
import time
import requests
API_BASE = "https://cdn.12ai.org"
API_KEY = "sk-xxx"
task = requests.post(
f"{API_BASE}/v1/videos",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"model": "seedance-2-official",
"mode": "text_to_video",
"prompt": "一只橘猫在花园里追逐蝴蝶,慢动作,电影级画质",
"duration": 5,
"resolution": "480p",
"ratio": "16:9",
},
timeout=60,
).json()
task_id = task["id"]
while True:
result = requests.get(
f"{API_BASE}/v1/videos/{task_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=60,
).json()
if result["status"] == "completed":
print(result.get("data", [{}])[0].get("url") or result.get("video_url"))
break
if result["status"] == "failed":
raise RuntimeError(result.get("error", {}).get("message", "生成失败"))
time.sleep(3)注意事项
| 项目 | 说明 |
|---|---|
| 素材 URL | 需要公网可访问 |
| 多素材引用 | 提示词中可以用“第一张图”“第二段视频”等方式指代素材 |
| 人脸素材 | 优先使用 -beta-face 系列模型 |
| 轮询间隔 | 建议每 2 到 3 秒查询一次 |
