下载视频
GET/v1/videos/{id}/content
仅 completed 状态可下载,成功时直接返回二进制文件,Content-Type: video/mp4。
cURL
curl -o video.mp4 "https://www.wyun.cloud/v1/videos/task_xxx/content" \ -H "Authorization: Bearer sk-你的密钥"
兼容 OpenAI Videos API 的异步视频生成接口,支持文生视频、首帧 / 首尾帧图生视频、多图参考,最长 30 秒、最高 4K。
POST /v1/videosGET /v1/videos/{id}GET /v1/videos/{id}/content5 秒视频通常 1~3 分钟生成完毕,时长越长、分辨率越高耗时越久。
# ① 提交 curl -X POST "https://www.wyun.cloud/v1/videos" \ -H "Authorization: Bearer sk-你的密钥" \ -H "Content-Type: application/json" \ -d '{ "model": "doubao-seedance-2-0-fast", "prompt": "明亮的摄影棚里,一只红色陶瓷杯在木桌上缓慢旋转,镜头平稳推进", "seconds": 5, "resolution": "480p" }' # ② 查询(每 10~15 秒一次,直到 completed / failed) curl "https://www.wyun.cloud/v1/videos/task_xxx" \ -H "Authorization: Bearer sk-你的密钥" # ③ 下载 curl -o video.mp4 "https://www.wyun.cloud/v1/videos/task_xxx/content" \ -H "Authorization: Bearer sk-你的密钥"
| 项目 | 值 |
|---|---|
| Base URL | https://www.wyun.cloud |
| 鉴权 | 请求头 Authorization: Bearer sk-xxxxxxxx |
| 请求格式 | application/json;上传本地图片时用 multipart/form-data |
| 字符编码 | UTF-8 |
获取密钥:登录 控制台 → 令牌 → 添加令牌 → 复制以 sk- 开头的密钥。
| 模型 ID | 定位 | 时长(秒) | 分辨率 | 智能时长 |
|---|---|---|---|---|
doubao-seedance-2-0 | 标准版,画质优先 | 4~15 | 480p720p1080p4k | — |
doubao-seedance-2-0-mini | 轻量版,性价比 | 4~15 | 480p720p | ✓ |
doubao-seedance-2-0-fast | 极速版,出片快 | 4~15 | 480p720p | ✓ |
doubao-seedance-2-5 | 新一代,支持长视频 | 4~30 | 480p720p1080p4k* | ✓ |
* 2.5 的 4k 仅支持纯文生视频。智能时长:传 seconds: -1 由模型自行决定长度。
支持的画面比例:16:9 9:16 4:3 1:1 3:4 21:9
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 ID,见模型列表 |
prompt | string | 是* | 画面描述。纯文生视频必填;图生视频建议填写,用于描述运动与镜头 |
seconds | integer | 否 | 视频时长(秒),也可写作 duration。支持智能时长的模型可传 -1 |
resolution | string | 否 | 480p / 720p / 1080p / 4k,需在模型支持范围内 |
aspect_ratio | string | 否 | 画面比例,如 16:9、9:16 |
generate_audio | boolean | 否 | 是否同步生成音频(音效 / 环境声) |
input_reference | string / file | 否 | 首帧图片。传入后为图生视频,视频从这张图开始 |
last_frame | string | 否 | 尾帧图片。需与 input_reference 同时使用 |
reference_images | string[] | 否 | 参考图(人物 / 商品 / 风格),不作为首帧,用于保持外观一致 |
https:// 直链,能直接打开图片本身(不能是网盘分享页、预览页或需登录的地址)data:image/png;base64,...,推荐 PNGmultipart/form-data 上传,字段名 input_reference,一次一个文件input_reference 与参考图 reference_images 不能同时使用
{
"id": "task_Jojj1wJXjyL2ru69ascYECy1FFTp1Xfu",
"object": "video",
"model": "doubao-seedance-2-0-fast",
"status": "queued",
"progress": 0,
"created_at": 1796227349
}请保存好 id,后续查询与下载都需要它。
{
"model": "doubao-seedance-2-0",
"prompt": "清晨的江南水乡,薄雾笼罩,一叶小舟缓缓划过石桥,镜头从远景慢慢推近",
"seconds": 8,
"resolution": "1080p",
"aspect_ratio": "16:9",
"generate_audio": true
}
// 只传 input_reference = 首帧图生视频;再加 last_frame = 首尾帧控制 { "model": "doubao-seedance-2-0", "prompt": "人物从站立姿态自然转身,看向镜头微笑", "seconds": 5, "resolution": "720p", "input_reference": "https://your-cdn.com/first.jpg", "last_frame": "https://your-cdn.com/last.jpg" }
curl -X POST "https://www.wyun.cloud/v1/videos" \ -H "Authorization: Bearer sk-你的密钥" \ -F "model=doubao-seedance-2-0-fast" \ -F "prompt=镜头缓慢环绕主体,背景虚化" \ -F "seconds=5" \ -F "resolution=720p" \ -F "input_reference=@./first.png"
{
"model": "doubao-seedance-2-5",
"prompt": "参考图中的女孩穿着同款外套,在雪地里奔跑,镜头跟随",
"seconds": 10,
"resolution": "1080p",
"aspect_ratio": "9:16",
"reference_images": [
"https://your-cdn.com/girl.jpg",
"https://your-cdn.com/coat.jpg"
]
}
{
"id": "task_Jojj1wJXjyL2ru69ascYECy1FFTp1Xfu",
"object": "video",
"model": "doubao-seedance-2-0-fast",
"status": "in_progress",
"progress": 50,
"created_at": 1796227349
}
{
"id": "task_Jojj1wJXjyL2ru69ascYECy1FFTp1Xfu",
"object": "video",
"model": "doubao-seedance-2-0-fast",
"status": "completed",
"progress": 100,
"created_at": 1796227349,
"completed_at": 1796227489,
"url": "https://...mp4?Expires=..."
}
{
"id": "task_xxx",
"object": "video",
"status": "failed",
"progress": 100,
"error": { "code": "...", "message": "失败原因" }
}
| status | 含义 | 你该做什么 |
|---|---|---|
queued | 排队中 | 继续轮询 |
in_progress | 生成中 | 继续轮询 |
completed | 已完成 | 下载视频 |
failed | 失败 | 查看 error.message;失败任务自动退还费用 |
url 是临时签名链接,约 15 分钟后失效,请及时转存或使用下方下载接口。仅 completed 状态可下载,成功时直接返回二进制文件,Content-Type: video/mp4。
curl -o video.mp4 "https://www.wyun.cloud/v1/videos/task_xxx/content" \ -H "Authorization: Bearer sk-你的密钥"
提交 → 轮询 → 下载的完整流程,替换密钥即可运行。
import time import requests BASE = "https://www.wyun.cloud" HEADERS = {"Authorization": "Bearer sk-你的密钥"} def create_video(payload: dict) -> str: r = requests.post(f"{BASE}/v1/videos", json=payload, headers=HEADERS, timeout=60) r.raise_for_status() return r.json()["id"] def wait_video(task_id: str, interval=12, timeout=900) -> dict: deadline = time.time() + timeout while time.time() < deadline: r = requests.get(f"{BASE}/v1/videos/{task_id}", headers=HEADERS, timeout=30) r.raise_for_status() data = r.json() print(data["status"], data.get("progress", 0), "%") if data["status"] == "completed": return data if data["status"] == "failed": raise RuntimeError(data.get("error", {}).get("message", "生成失败")) time.sleep(interval) raise TimeoutError("等待超时") def download(task_id: str, path: str): with requests.get(f"{BASE}/v1/videos/{task_id}/content", headers=HEADERS, stream=True, timeout=300) as r: r.raise_for_status() with open(path, "wb") as f: for chunk in r.iter_content(1 << 20): f.write(chunk) if __name__ == "__main__": tid = create_video({ "model": "doubao-seedance-2-0-fast", "prompt": "一只橘猫在窗台上伸懒腰,阳光洒进来", "seconds": 5, "resolution": "720p", "aspect_ratio": "16:9", }) print("任务ID:", tid) wait_video(tid) download(tid, "cat.mp4") print("已保存 cat.mp4")
// Node.js 18+ import { writeFile } from "node:fs/promises"; const BASE = "https://www.wyun.cloud"; const HEADERS = { Authorization: "Bearer sk-你的密钥" }; const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); async function main() { // ① 提交 const res = await fetch(`${BASE}/v1/videos`, { method: "POST", headers: { ...HEADERS, "Content-Type": "application/json" }, body: JSON.stringify({ model: "doubao-seedance-2-0-fast", prompt: "一只橘猫在窗台上伸懒腰,阳光洒进来", seconds: 5, resolution: "720p", }), }); if (!res.ok) throw new Error(await res.text()); const { id } = await res.json(); console.log("任务ID:", id); // ② 轮询 for (;;) { await sleep(12000); const s = await (await fetch(`${BASE}/v1/videos/${id}`, { headers: HEADERS })).json(); console.log(s.status, s.progress + "%"); if (s.status === "completed") break; if (s.status === "failed") throw new Error(s.error?.message || "生成失败"); } // ③ 下载 const v = await fetch(`${BASE}/v1/videos/${id}/content`, { headers: HEADERS }); await writeFile("cat.mp4", Buffer.from(await v.arrayBuffer())); console.log("已保存 cat.mp4"); } main().catch(console.error);
seconds 或传 -1(智能时长)时,按该模型最长时长计费(2.0 系列 15 秒、2.5 为 30 秒),建议始终明确指定时长。出错时返回非 2xx 状态码,响应体格式:
{
"error": {
"message": "duration must be between 4 and 15 for this model",
"type": "...",
"code": "..."
}
}| 状态码 | 含义 | 处理建议 |
|---|---|---|
| 400 | 参数错误 | 按 message 修改参数,见下表 |
| 401 | 密钥无效或缺失 | 检查 Authorization 头与密钥是否正确、是否已删除 |
| 403 | 无权使用该模型 / 令牌禁用 | 检查令牌的模型限制与分组 |
| 404 | 任务不存在 | 检查任务 id;只能查询本账号的任务 |
| 429 | 请求过于频繁 | 降低频率,稍后重试 |
| 余额不足 | 账户额度不足 | 前往控制台充值 |
| 5xx | 服务暂时异常 | 稍后重试;提交超时时先查询再决定是否重提,避免重复扣费 |
| 错误信息 | 原因与解决 |
|---|---|
duration must be between 4 and 15 for this model | 时长超出范围。2.0 系列 4~15 秒,2.5 为 4~30 秒 |
resolution must be one of 480p, 720p for this model | mini / fast 只支持 480p、720p |
aspect_ratio must be one of ... | 使用模型列表中的比例 |
... must be an https URL | 图片地址需为 https 直链,或改用 Base64 / 文件上传 |
Seedance 2.5 supports 4k for text-to-video only | 2.5 图生视频不支持 4k,降到 1080p 或改为纯文生 |
a last_frame image requires a first_frame image | 只传了尾帧,需同时传 input_reference |
a reference request cannot carry first_frame or last_frame images | 首帧与参考图不能混用,二选一 |
only one input file is supported | multipart 一次只能传一个文件,其余用 URL |
url 约 15 分钟过期,生成后尽快下载到自己的存储。高峰期需要排队,通常几分钟内开始。超过 15 分钟仍未开始,请联系客服并提供任务 id。
临时链接已过期,改用 GET /v1/videos/{id}/content 下载。
接口路径与 OpenAI Videos API 一致,可将 SDK 的 base_url 设为 https://www.wyun.cloud/v1,额外参数(如 resolution、last_frame)通过 extra_body 传入。不同 SDK 版本行为可能有差异,推荐直接使用上方 HTTP 示例。
控制台:www.wyun.cloud · 技术支持:(在此填写客服微信 / QQ 群 / 邮箱)