用 API Key 上传参考素材、提交豆包画布视频任务、实时查询进度、在线播放或下载成片。每个成员只能看到自己的任务,站长可以看到全部任务。
生成会消耗站长豆包账号的视频额度。提交前请确认额度;任务一旦被豆包受理,取消也未必能回滚额度。
所有 /api/v1 接口都需要 API Key,放在请求头里:
Authorization: Bearer lvs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
也支持 X-API-Key: lvs_xxx。Key 由站长在控制台「成员」或「接入 API」页生成,只显示一次。
curl "https://你的域名/api/v1/me" \ -H "Authorization: Bearer lvs_xxx"
成功会返回当前成员、角色、今日提交数等信息。Key 无效返回 401。
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /api/v1/me | 当前 Key 对应的成员信息、今日提交数 |
| GET | /api/v1/models | 模型、比例、时长范围、可用状态、任务状态 |
| POST | /api/v1/uploads | 上传参考素材(multipart,字段名 files) |
| POST | /api/v1/tasks | 创建任务(支持图片、视频、音频、自动拆分分镜) |
| GET | /api/v1/tasks | 我的任务列表,支持 state、limit |
| GET | /api/v1/tasks/:id | 任务详情 + 进度 |
| POST | /api/v1/tasks/:id/cancel | 取消任务(尽力而为) |
| POST | /api/v1/tasks/:id/retry | 重新排队 |
| DELETE | /api/v1/tasks/:id | 删除任务记录(不删成片文件) |
| GET | /api/v1/tasks/:id/media | 在线播放成片(支持 Range,可拖动进度) |
| GET | /api/v1/tasks/:id/download | 下载成片 mp4 |
支持一次上传多个文件,字段名固定为 files:
curl -X POST "https://你的域名/api/v1/uploads" \ -H "Authorization: Bearer lvs_xxx" \ -F "files=@ref1.png" \ -F "files=@ref2.jpg" \ -F "files=@ref-video.mp4" \ -F "files=@ref-audio.mp3"
返回:
{
"ok": true,
"files": [
{
"name": "ref1.png",
"path": "data/refs/usr_xxx/1710000000000_ab12cd34ef56.png",
"size": 123456,
"kind": "image",
"url": "/refs/usr_xxx/1710000000000_ab12cd34ef56.png"
}
]
}
| 类型 | 格式 | 数量 | 大小 |
|---|---|---|---|
| 图片 | PNG / JPEG / WebP | 最多 10 张 | 单张 ≤ 20MB |
| 视频 | MP4 / WebM / MOV | 最多 1 个 | 单个 ≤ 100MB |
| 音频 | MP3 / WAV / M4A / AAC | 最多 1 个 | 单个 ≤ 100MB |
创建任务时把返回的 path 分别放进 images / video / audio。不能直接使用外链素材。
参考视频与参考音频二选一;带参考视频会自动使用 Seedance 2.0 Fast。图片可以和视频/音频一起用。
curl -X POST "https://你的域名/api/v1/tasks" \
-H "Authorization: Bearer lvs_xxx" \
-H "Content-Type: application/json" \
-d '{
"text": "一只猫在草地上奔跑,阳光,电影感",
"model": "Seedance2.0mini",
"ratio": "16:9",
"duration": 5,
"split": false
}'
{
"text": "剧情66:分镜1-1\n镜头:雨夜街头,主角撑伞回头",
"model": "Seedance2.0mini",
"ratio": "9:16",
"duration": 5,
"split": true,
"images": [
"data/refs/usr_xxx/1710000000000_ab12cd34ef56.png",
"data/refs/usr_xxx/1710000000001_cd34ef56ab12.jpg"
]
}
{
"text": "延续参考视频的运镜,雨夜街头,主角回头",
"ratio": "16:9",
"duration": 5,
"video": "data/refs/usr_xxx/1710000000002_ef56ab12cd34.mp4"
}
带 video 时模型会自动使用 Seedance2.0Fast,不需要手动传 model。
{
"text": "跟随参考音频的节奏做卡点视频",
"model": "Seedance2.0mini",
"ratio": "16:9",
"duration": 5,
"audio": "data/refs/usr_xxx/1710000000003_ab12ef56cd34.mp3"
}
video 和 audio 不能同时传,会返回 400。
| 字段 | 必填 | 说明 |
|---|---|---|
text | 是 | 提示词。开启 split 时按「剧情66:分镜1-1」拆分 |
model | 否 | 默认取站长设置。Seedance2.0Fast / Seedance2.0mini 始终可用;Seedance2.5 / Seedance2.5Flash / Seedance2.0 需要账号已开通豆包订阅,否则 400 |
ratio | 否 | auto / 16:9 / 9:16 / 1:1 / 4:3 / 3:4 |
duration | 否 | 整数秒,1–30;常见 5–15,实际以模型为准 |
split | 否 | 默认 true,按分镜小标题拆成多条任务;纯提示词建议传 false |
images | 否 | 参考图 path 数组,最多 10 张,本批所有分镜共用 |
video | 否 | 参考视频 path;自动使用 Fast;与 audio 二选一 |
audio | 否 | 参考音频 path;与 video 二选一 |
{
"ok": true,
"count": 2,
"tasks": [
{
"id": "vj_53a19878507dcb66",
"name": "剧情66_分镜1-1_AB12CD34",
"state": "queued",
"phase": "queued",
"phaseText": "排队中",
"progress": 0,
"model": "Seedance2.0mini",
"ratio": "9:16",
"duration": 5,
"imageCount": 2,
"hasVideo": false,
"hasAudio": false,
"createdAt": 1710000000000,
"mediaUrl": "",
"downloadUrl": ""
}
]
}
任务状态:
queued(排队中) → running(执行中:preparing → submitting → generating → downloading) → completed(已完成) → failed(失败) → canceled(已取消)
每次查询任务详情都会返回这些进度字段:
| 字段 | 说明 |
|---|---|
state | queued / running / completed / failed / canceled |
phase | 当前阶段:queued / preparing / submitting / generating / downloading / completed / failed / canceled |
phaseText | 阶段中文说明,可直接展示给用户 |
progress | 0–100 的整数进度,生成阶段会随时间缓慢推进 |
stepMessage | 最新一条步骤说明,例如「参考素材 2/2 已提交上传」 |
steps | 最近步骤数组:{ at, state, message } |
waiting | 等待原因,例如「等待可用账号」 |
error | 失败原因,仅失败时有值 |
进度映射:
queued 0% preparing 10% 准备画布、模型、比例、素材 submitting 25% 已点提交 generating 50% 等待豆包出片(随时间推进,最高 80%) downloading 85% 下载成片 completed 100% failed 100%(红色) canceled 100%
建议轮询间隔 3–5 秒,任务到 completed / failed / canceled 后停止。
curl "https://你的域名/api/v1/tasks/vj_xxx" \ -H "Authorization: Bearer lvs_xxx"
async function waitTask(id) {
const base = 'https://你的域名';
const key = process.env.LVS_API_KEY;
while (true) {
const response = await fetch(`${base}/api/v1/tasks/${id}`, {
headers: { Authorization: `Bearer ${key}` },
});
const { task } = await response.json();
console.log(`${task.phaseText} ${task.progress}% ${task.stepMessage || ''}`);
if (['completed', 'failed', 'canceled'].includes(task.state)) return task;
await new Promise((resolve) => setTimeout(resolve, 4000));
}
}
import time, requests
BASE = "https://你的域名"
KEY = "lvs_xxx"
HEADERS = {"Authorization": f"Bearer {KEY}"}
def wait_task(task_id):
while True:
task = requests.get(f"{BASE}/api/v1/tasks/{task_id}", headers=HEADERS, timeout=30).json()["task"]
print(task["phaseText"], task["progress"], task.get("stepMessage", ""))
if task["state"] in ("completed", "failed", "canceled"):
return task
time.sleep(4)
任务完成后返回两个地址:
| 字段 | 用途 |
|---|---|
mediaUrl | 在线播放,支持 HTTP Range(可拖动进度条) |
downloadUrl | 下载 mp4 文件 |
resultSize | 成片字节数 |
curl -L "https://你的域名/api/v1/tasks/vj_xxx/download" \ -H "Authorization: Bearer lvs_xxx" \ -o result.mp4
这两个地址都需要带 API Key 请求头。浏览器里要直接播放时,先 fetch 成 blob 再播放:
async function playTask(id, key) {
const response = await fetch(`https://你的域名/api/v1/tasks/${id}/media`, {
headers: { Authorization: `Bearer ${key}` },
});
const blob = await response.blob();
document.querySelector('#player').src = URL.createObjectURL(blob);
}
| HTTP | 含义 |
|---|---|
| 400 | 参数不合法、素材路径无效、视频和音频同时传、模型需要订阅等 |
| 401 | 没有带 API Key,或 Key 已被重置/停用 |
| 404 | 任务不存在,或不是你的任务 |
| 429 | 提交/上传太频繁,稍后再试 |
接口限流:每个成员每分钟最多提交 30 次、上传 30 次。
const fs = require('fs');
const BASE = 'https://你的域名';
const KEY = process.env.LVS_API_KEY;
async function upload(filePath) {
const form = new FormData();
form.append('files', new Blob([fs.readFileSync(filePath)]), filePath.split(/[\\/]/).pop());
const response = await fetch(`${BASE}/api/v1/uploads`, {
method: 'POST',
headers: { Authorization: `Bearer ${KEY}` },
body: form,
});
const data = await response.json();
if (!response.ok) throw new Error(data.error);
return data.files[0];
}
async function createTask(prompt, images) {
const response = await fetch(`${BASE}/api/v1/tasks`, {
method: 'POST',
headers: {
Authorization: `Bearer ${KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: prompt,
model: 'Seedance2.0mini',
ratio: '16:9',
duration: 5,
split: false,
images: images.map((item) => item.path),
}),
});
const data = await response.json();
if (!response.ok) throw new Error(data.error);
return data.tasks[0];
}
async function main() {
const image = await upload('./ref1.png');
const task = await createTask('一只猫在草地上奔跑,电影感', [image]);
console.log('已提交', task.id);
while (true) {
const response = await fetch(`${BASE}/api/v1/tasks/${task.id}`, {
headers: { Authorization: `Bearer ${KEY}` },
});
const { task: info } = await response.json();
console.log(info.phaseText, info.progress + '%', info.stepMessage || '');
if (info.state === 'completed') {
console.log('成片地址', BASE + info.mediaUrl);
break;
}
if (info.state === 'failed') throw new Error(info.error);
await new Promise((resolve) => setTimeout(resolve, 4000));
}
}
main().catch((error) => {
console.error(error);
process.exit(1);
});