Seedance 2.5 视频生成
seedance2.5 支持文生视频以及图片、视频、音频等参考素材驱动的视频生成。推荐使用异步任务接口,创建后通过任务 ID 查询进度。
调用前准备
选择专用分组
创建令牌时必须选择 【图片视频专用分组】。Seedance 2.5 按生成秒数计费,参考价格为 ¥0.40/秒。
例如,生成 4 秒视频的参考费用为 ¥1.60。模型和价格可能调整,请以控制台及实时定价为准。
异步调用流程
| 步骤 | 方法与路径 | 说明 |
|---|---|---|
| 1. 创建任务 | POST /v1/videos | 返回任务 id 和 queued 状态 |
| 2. 查询任务 | GET /v1/videos/{id} | 建议每 10–15 秒查询一次 |
| 3. 获取视频 | 响应中的 video_url | completed 后直接下载 |
不要依赖同步等待
实测在创建请求中增加 wait: true 仍会返回排队中的异步任务。请保存 id 并执行轮询,避免长连接超时或重复提交计费任务。
创建文生视频任务
bash
curl https://ai.flashapi.top/v1/videos \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance2.5",
"prompt": "a cute kitten playing with a ball of yarn, cinematic lighting",
"size": "1280x720",
"seconds": "4",
"generate_audio": false
}'创建图生视频任务
参考图可以是公网可直连 URL,也可以是 data: base64。多张图片可使用 images 数组。
bash
curl https://ai.flashapi.top/v1/videos \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance2.5",
"prompt": "slow cinematic push-in, drifting clouds, golden hour",
"size": "1280x720",
"seconds": "4",
"input_reference": "https://example.com/reference.jpg"
}'请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 固定为 seedance2.5 |
prompt | string | 条件必填 | 视频内容、运镜和风格描述;未提供 content 时必填 |
seconds | string | 否 | 时长字符串,范围 "4"–"30",默认 "4" |
duration | integer | 否 | 时长整数,范围 4–30;与 seconds 二选一 |
size | string | 否 | 宽x高,例如 1280x720 |
ratio | string | 否 | auto、21:9、16:9、4:3、1:1、3:4、9:16;覆盖 size 的比例 |
resolution | string | 否 | 480p 或 720p |
generate_audio | boolean | 否 | 是否生成音频,默认 true |
seed | integer | 否 | 随机种子;-1 表示随机 |
input_reference | string / array | 否 | 参考素材 URL 或 data: base64 |
images | string / array | 否 | 参考图片,最多 30 张 |
content | array | 否 | 多模态内容;可替代顶层提示词和参考素材 |
多模态参考素材
content 支持 text、image_url、video_url 和 audio_url。图片最多 30 张,视频最多 10 个,音频最多 10 个。
json
{
"model": "seedance2.5",
"seconds": "4",
"ratio": "16:9",
"resolution": "720p",
"content": [
{"type": "text", "text": "gentle camera push-in, soft morning light"},
{
"type": "image_url",
"image_url": {"url": "https://example.com/reference.jpg"}
}
]
}参考 URL 必须公网可访问并允许服务端下载。无法直连时建议改用 data: base64 或可直连的对象存储地址。
创建任务响应
json
{
"id": "video_976521f793cf4d80a7b1a091",
"object": "video",
"model": "seedance2.5",
"status": "queued",
"progress": 0,
"seconds": "4",
"size": "1280x720",
"created_at": 1785248785
}查询任务
bash
curl https://ai.flashapi.top/v1/videos/video_976521f793cf4d80a7b1a091 \
-H "Authorization: Bearer YOUR_API_KEY"处理中:
json
{
"id": "video_976521f793cf4d80a7b1a091",
"object": "video",
"status": "in_progress",
"progress": 35,
"seconds": "4"
}完成:
json
{
"id": "video_976521f793cf4d80a7b1a091",
"object": "video",
"status": "completed",
"progress": 100,
"seconds": "4",
"video_url": "https://example-cdn.com/generated-video.mp4",
"completed_at": 1785249046,
"usage": {"seconds": 4, "video_count": 1}
}失败:
json
{
"id": "video_976521f793cf4d80a7b1a091",
"status": "failed",
"error": {
"code": "generation_failed",
"message": "content moderated"
}
}| 状态 | 含义 |
|---|---|
queued | 已进入队列 |
in_progress / processing | 正在生成,可读取 progress(若返回) |
completed | 已完成,可读取 video_url |
failed | 失败,查看 error.message |
Python 完整示例
python
import os
import time
import requests
api_key = os.environ["FLASH_API_KEY"]
base_url = "https://ai.flashapi.top"
headers = {"Authorization": f"Bearer {api_key}"}
created = requests.post(
f"{base_url}/v1/videos",
headers=headers,
json={
"model": "seedance2.5",
"prompt": "a red hot air balloon over green mountains at sunrise",
"size": "1280x720",
"seconds": "4",
"generate_audio": False,
},
timeout=60,
)
created.raise_for_status()
task_id = created.json()["id"]
deadline = time.monotonic() + 20 * 60
while time.monotonic() < deadline:
try:
response = requests.get(
f"{base_url}/v1/videos/{task_id}", headers=headers, timeout=30
)
response.raise_for_status()
task = response.json()
except requests.RequestException:
time.sleep(12)
continue
if task["status"] == "completed":
print(task["video_url"])
break
if task["status"] == "failed":
raise RuntimeError(task.get("error", "视频生成失败"))
time.sleep(12)
else:
raise TimeoutError(f"任务 {task_id} 在 20 分钟内未完成,可稍后继续查询")常见问题
| 现象 | 处理方式 |
|---|---|
| 参考素材返回 HTTP 403 | 素材站点阻止服务端下载;改用可直连 URL 或 data: base64 |
content moderated | 调整提示词或参考素材后重试 |
上游限流或 DataDome 429 | 等待渠道恢复后重试;不要连续重复创建任务 |
| 轮询发生网络错误 | 继续使用相同任务 ID 轮询,不要立即重建任务 |
注意事项
- 建议每 10–15 秒轮询一次,整体超时不少于 20 分钟。
- 720p 是当前支持的最高分辨率;传入更高分辨率可能被降为 720p。
- 完成后直接使用
video_url,当前不建议依赖/v1/videos/{id}/content。 - 视频计费与请求的生成时长有关,测试时建议先使用 4 秒。