视频生成
POST /v1/videos · GET /v1/videos/{id} · DELETE /v1/videos/{id}
根据文本提示词生成短视频,可选传入首/尾参考帧控制画面。这是业界标准 create + poll 形态的异步任务 API:POST /v1/videos 约 2 秒返回任务对象,轮询至完成;加 Prefer: wait 头可让快速生成一次调用直达结果。Seedance 系列模型,一把 API key,计费与其他端点一致。
视频 API 目前为受限预览(邀请测试)。模型会出现在目录和价格中,但创建任务需要你的 workspace 在白名单内——请联系我们为你的 workspace 开通。
端点与任务生命周期
一个任务资源,四种操作。任务状态流转:queued → in_progress → 终态之一(completed、failed 或 cancelled)。创建响应自带 status_url / cancel_url 链接,无需手工拼 URL。
| 端点 | 说明 |
|---|---|
POST /v1/videos | 创建生成任务。约 2 秒返回任务对象(status queued)及轮询链接。 |
GET /v1/videos/{id} | 轮询任务。completed 时返回 data[0].url、usage.completion_tokens 及实际生效参数;failed 时返回结构化错误(上游 code 与 message)。 |
DELETE /v1/videos/{id} | 取消任务。仅排队中(queued)的任务可取消;取消的任务不收费。 |
GET /v1/videos/models | 列出你的 key 可用的视频模型,含每个模型的分辨率/时长约束与价格。 |
同步糖 —— Prefer: wait
在创建请求上加 Prefer: wait 或 Prefer: wait=N 头(N 限制在 1..60 秒),网关会保持连接等待。任务在窗口内完成则直接返回终态对象——含视频 URL 与用量,无需轮询;未在窗口内完成则优雅降级:返回当前状态对象(不报错,任务照常运行),继续正常轮询即可。
请求体
| 参数 | 类型 | 说明 |
|---|---|---|
model* | string | 要使用的视频模型(如 seedance-1-5-pro-251215)。通过 GET /v1/videos/models 列出全部可用模型。 |
prompt* | string | 目标视频的文本描述。 |
image | string | string[] | 图生视频输入:1 张图 = 首帧,2 张图 = 首帧 + 尾帧。每项为 data URI 或 https URL。 |
resolution | string | 输出分辨率:480p、720p、1080p 或 4k。各模型支持的集合不同——见模型表。 |
ratio | string | 画面比例:16:9、4:3、1:1、3:4、9:16、21:9 或 adaptive。 |
duration | integer | 片长(秒,各模型范围在 2..15 内)。部分模型支持 -1,由模型自选片长。 |
seed | integer | 可选随机种子,用于可复现输出(视模型支持)。 |
watermark | boolean | 是否渲染供应商水印。 |
generate_audio | boolean | 是否生成音轨(默认 true)。对分档计费的模型会影响价格——见模型表。 |
可用模型
模型可用性取决于你的部署。通过 GET /v1/videos/models获取实时、合规感知的完整列表(含每模型分辨率/时长约束与价格)。当前阵容:
| 模型 | 分辨率 | 时长 | 价格 | 备注 |
|---|---|---|---|---|
dreamina-seedance-2-0-260128 | 480p · 720p · 1080p · 4k | 4–15 s | 480p/720p $7.0 · 1080p $7.7 · 4k $4.0 | 2.0 旗舰;最高 4K |
dreamina-seedance-2-0-fast-260128 | 480p · 720p | 4–15 s | $5.6 | 2.0 提速版 |
dreamina-seedance-2-0-mini-260615 | 480p · 720p | 4–15 s | $3.5 | 2.0 最小版 |
seedance-1-5-pro-251215 | 480p · 720p · 1080p | 4–12 s | $2.4 audio · $1.2 muted | 费率随 generate_audio 变化 |
seedance-1-0-pro-fast-251015 | 480p · 720p · 1080p | 2–12 s | $1.0 | 最便宜 |
价格:USD / 1M video tokens。seedance-1-5-pro-251215 开音轨(generate_audio: true,默认)$2.4、关音轨 $1.2;其余模型按分辨率档单一费率。
video token 与定价
视频按 video token 计费,由实际输出推导:tokens ≈ 宽 × 高 × 24 fps × 秒 / 1024。费率按每 1M video tokens 计,以实际生效参数(completed 任务中回显)为准——因此 ratio: "adaptive" 与 duration: -1 都按模型实际产出计费。
直观锚点(seedance-1-5-pro-251215 有声):480p / 16:9 / 4 秒 ≈ 40.6K video tokens ≈ $0.10;720p / 5 秒 ≈ 108.9K tokens ≈ $0.26。
计费
仅成功才计费:任务首次到达 completed 时结算一次,按回传的 video token 用量计价。失败任务(含内容审核拒绝)与取消任务一律不收费——上游错误原样透传,便于定位原因。
返回的 data[0].url 是预签名的供应商 URL,约 24 小时后失效——请及时下载;需长期保存请转存到你自己的存储。
示例 —— curl 一步到位(Prefer: wait)
curl https://synthorai.io/v1/videos \
-H "Authorization: Bearer $SYNTHORAI_API_KEY" \
-H "Content-Type: application/json" \
-H "Prefer: wait=60" \
-d '{
"model": "seedance-1-0-pro-fast-251015",
"prompt": "A corgi puppy chasing a butterfly across a meadow, cinematic",
"resolution": "480p",
"ratio": "16:9",
"duration": 4
}'
# Finished inside the wait window → the terminal object comes straight back:
{
"id": "vid_6091d8d1af805818b1470488",
"object": "video",
"model": "seedance-1-0-pro-fast-251015",
"status": "completed",
"data": [{ "url": "https://…tos….mp4?…" }],
"usage": { "completion_tokens": 40594, "total_tokens": 40594 },
"resolution": "480p", "ratio": "16:9", "duration": 4, "fps": 24,
"seed": 34142
}
# Not done in time → the current status object is returned instead (no error,
# the task keeps running) — continue polling status_url as usual. 示例 —— curl 创建 + 轮询
# 1) Create — returns in ~2 s with a queued task object
curl https://synthorai.io/v1/videos \
-H "Authorization: Bearer $SYNTHORAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-1-5-pro-251215",
"prompt": "A corgi puppy chasing a butterfly across a meadow, cinematic",
"resolution": "720p",
"duration": 5,
"generate_audio": true
}'
{
"id": "vid_6091d8d1af805818b1470488",
"object": "video",
"model": "seedance-1-5-pro-251215",
"status": "queued",
"created_at": 1784619862,
"status_url": "https://synthorai.io/v1/videos/vid_6091d8d1af805818b1470488",
"cancel_url": "https://synthorai.io/v1/videos/vid_6091d8d1af805818b1470488"
}
# 2) Poll until status is terminal (completed | failed | cancelled)
curl https://synthorai.io/v1/videos/vid_6091d8d1af805818b1470488 \
-H "Authorization: Bearer $SYNTHORAI_API_KEY"
{
"id": "vid_6091d8d1af805818b1470488",
"object": "video",
"model": "seedance-1-5-pro-251215",
"status": "completed",
"data": [{ "url": "https://…tos….mp4?…" }],
"usage": { "completion_tokens": 108900, "total_tokens": 108900 },
"resolution": "720p", "ratio": "16:9", "duration": 5, "fps": 24,
"seed": 34142, "generate_audio": true
}
# 3) Download the video — the URL is pre-signed (no auth header) and expires
# in ~24 h: fetch promptly and re-host if you need it long-term.
curl -o out.mp4 "https://…tos….mp4?…" 示例 —— Python(requests)
import time
import requests
BASE = "https://synthorai.io/v1"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}
task = requests.post(f"{BASE}/videos", headers=HEADERS, json={
"model": "seedance-1-5-pro-251215",
"prompt": "A corgi puppy chasing a butterfly across a meadow, cinematic",
"resolution": "720p",
"duration": 5,
}).json()
while task["status"] not in ("completed", "failed", "cancelled"):
time.sleep(5)
task = requests.get(task["status_url"], headers=HEADERS).json()
if task["status"] == "completed":
url = task["data"][0]["url"] # pre-signed, valid ~24 h — re-host promptly
with open("out.mp4", "wb") as f:
f.write(requests.get(url).content)
else:
print(task["error"]) # provider code + message, passed through verbatim 示例 —— Node(fetch)
import fs from "node:fs";
const BASE = "https://synthorai.io/v1";
const HEADERS = { Authorization: `Bearer ${process.env.SYNTHORAI_API_KEY}` };
let task = await (await fetch(`${BASE}/videos`, {
method: "POST",
headers: { ...HEADERS, "Content-Type": "application/json" },
body: JSON.stringify({
model: "seedance-1-5-pro-251215",
prompt: "A corgi puppy chasing a butterfly across a meadow, cinematic",
resolution: "720p",
duration: 5,
}),
})).json();
while (!["completed", "failed", "cancelled"].includes(task.status)) {
await new Promise((r) => setTimeout(r, 5000));
task = await (await fetch(task.status_url, { headers: HEADERS })).json();
}
if (task.status === "completed") {
const url = task.data[0].url; // pre-signed, valid ~24 h — re-host promptly
fs.writeFileSync("out.mp4", Buffer.from(await (await fetch(url)).arrayBuffer()));
} else {
console.error(task.error); // provider code + message, passed through verbatim
} 幂等性
传 X-Idempotency-Key 请求头让重试安全:相同 key 的重复请求返回 409,而不会二次创建(和二次计费)任务。视频生成慢、易超时重试,这能防止重复扣费。