Seedance 视频 API 接入
使用 Seedance 2.0 或 2.5 进行文生视频和图生视频,查询异步任务状态并下载生成结果。
Seedance 视频生成使用异步 Video API:先提交任务,再使用返回的任务 ID 查询状态。该接口与 Chat Completions 分开,不要请求 /v1/chat/completions。
开始前准备
创建 Modelflare API Key,并使用 https://modelflare.dev/v1 作为 Base URL。公开模型名为 seedance-2.0 和 seedance-2.5。
不同模型可用的时长与分辨率组合可能不同,请在请求前查看模型与价格页面。模型支持时,分辨率值使用 480p、720p、1080p 或 4k。
文生视频请求
curl https://modelflare.dev/v1/videos \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2.5",
"prompt": "雨夜霓虹街道上,一只白猫向镜头跑来,电影感,低机位跟拍",
"duration": 4,
"resolution": "720p"
}'
图生视频请求
增加 image 字段并传入可公开访问的 HTTPS 图片地址,其余字段与文生视频相同。
curl https://modelflare.dev/v1/videos \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2.5",
"prompt": "让画面主体缓慢转向镜头,镜头轻微推进,保持真实摄影风格",
"image": "https://example.com/reference.png",
"duration": 4,
"resolution": "720p"
}'
提交响应
提交成功后会返回公开任务 ID。id 与 task_id 表示同一个任务,保存任意一个即可继续查询。
{
"id": "task_example_123",
"task_id": "task_example_123",
"object": "video",
"model": "seedance-2.5",
"status": "queued"
}
查询任务状态
建议每隔数秒查询一次。等待状态可能是 queued、pending、processing 或 in_progress;状态变为 completed 或 failed 后停止轮询。
curl https://modelflare.dev/v1/videos/task_example_123 \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY"
任务完成响应示例:
{
"id": "task_example_123",
"task_id": "task_example_123",
"object": "video",
"model": "seedance-2.5",
"status": "completed",
"progress": 100,
"metadata": {
"url": "https://example.com/generated-video.mp4"
}
}
下载视频
任务完成后,通过 content 接口下载视频:
curl -L https://modelflare.dev/v1/videos/task_example_123/content \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \
-o seedance.mp4
主要入参
- model:必填,使用 seedance-2.0 或 seedance-2.5。
- prompt:必填,描述希望生成的视频。
- duration:必填,整数秒,当前最短为 4 秒;也兼容 seconds 字段。
- resolution:必填,使用当前模型支持的输出分辨率。
- image:可选,公开可访问的 HTTPS 图片地址;传入后执行图生视频。
HTTP 400 通常表示参数不正确,401 表示 API Key 无效,429 表示暂时受限,5xx 错误可在退避等待后重试。