视频生成
用 Seedance 2.5 生成视频 —— 文生视频 / 图生视频 / 视频生视频。
使用 Portrait 作为输入
在视频生成中通过 asset://<asset-id> 作为多模态输入引用虚拟人或真人 Portrait。asset:// 仅 seedance-2.0 / seedance-2.0-fast 支持 —— seedance-2.5 不支持。完整接入流程见 Portrait guide。
概述
使用 Seedance 模型,从文本提示词、参考图或参考视频生成电影感短视频。seedance-2.5 是当前旗舰,覆盖文生视频、图生视频与视频生视频(通过 reference_video 用一段参考视频驱动新片段)。
创建视频
Submit a video generation task using the Videos API:
| 1 | curl https://api.alltoken.ai/v1/videos/generations -H "Authorization: Bearer $ALLTOKEN_API_KEY" -H "Content-Type: application/json" -d '{ |
| 2 | "model": "seedance-2.5", |
| 3 | "prompt": "A serene mountain lake at sunrise, cinematic 4K", |
| 4 | "ratio": "16:9", |
| 5 | "duration": 5, |
| 6 | "resolution": "720p" |
| 7 | }' |
参考素材
除文本提示词外,Seedance 还能通过 content[] 数组接收参考图、参考视频与参考音频。每一项都有 type 和 role:
| 素材 | type | 可用 role |
|---|---|---|
| 图片 | image_url | reference_image、first_frame、last_frame |
| 视频 | video_url | reference_video |
| 音频 | audio_url | reference_audio |
每个素材有两种传法,且可在同一个请求里混用:
- 已在公网 —— 把
http(s)URL 填进 type 对象,例如{ "type": "image_url", "image_url": { "url": "https://..." }, "role": "reference_image" }。必须上游公网可达(不接受内网或需签名的私有链接)。 - 本地文件 —— 先预签名直传,再用返回的
upload_id引用:{ "type": "image_url", "upload_id": "upl_...", "role": "reference_image" }。
警告
data: base64 内联通路已于 2026-08-06 下线。带 data: 素材的视频请求现在会返回 400 inline_media_removed。迁移只需把内联 URL 换成 upload_id,其余字段不变。http(s) URL 与 upload_id 两条通路不受影响。
| 1 | - { "type": "image_url", "image_url": { "url": "data:image/png;base64,iVBOR..." }, "role": "reference_image" } |
| 2 | + { "type": "image_url", "upload_id": "upl_9f3c...", "role": "reference_image" } |
role 默认值与首尾帧规则
type 也可写简化形式 image / video / audio(网关会归一化),但不写 role 时会套默认值 —— 而图片的默认值可能出乎意料:
简化 type | 归一为 | 不写 role 时的默认值 |
|---|---|---|
image | image_url | first_frame —— 不是 reference_image! |
video | video_url | reference_video |
audio | audio_url | reference_audio |
也就是说 { "type": "image", "upload_id": "upl_..." } 会被当成首帧,不是参考图。建议一律用长写法 + 显式 role,不依赖默认值。GET 任务响应会回显识别到的 input_type,可用来核对网关如何解读你的 content[]。
警告
首尾帧与参考素材不能混用。上游把二者视为互斥范式:first_frame / last_frame(指定成片起止画面)对 reference_image / reference_video(提供风格或主体参考)。同一请求里同时出现两类画面素材会返回 400 invalid_request。reference_audio 不受此限 —— 「一张图当首帧 + 一段音频作参考」是受支持的组合。
素材硬约束
| 约束 | 数值 | 谁的限制 |
|---|---|---|
| 参考视频像素数 | ≥ 409,600(即 640×640 起步) | 上游模型 —— 我方原样透传 |
| 单文件直传上限 | 见 媒体上传 的 purpose 上限 | AllToken |
| 参考图数量 | 上游文档为 9 张;我方不做限制 | 上游 |
参考视频像素不足时,上游报错会原样透传(例如 InvalidParameter: ... video pixel count ... must be greater than or equal to 409600 ...)。另外 frames 与 camera_fixed 在 2.0 系列不支持,传了会被静默忽略而非报错。
支持的模型
调用 GET /videos/models 获取实时列表。seedance-2.5 是当前旗舰(文生视频、图生视频与视频生视频);asset:// Portrait 引用仍留在 2.0 系列。
| 模型 | 最适合 | asset:// Portrait 引用 |
|---|---|---|
seedance-2.5 | 旗舰 —— 文生 / 图生 / 视频生视频 | ❌ 不支持(Portrait 仅 2.0 系列) |
seedance-2.0 / seedance-2.0-fast | Portrait(asset://)工作流 | ✅ 支持 |
seedance-1.5-pro | 较早世代 | ❌ 不支持(使用普通图片 URL) |
See Portrait guide for how to obtain an asset_id.
参数
model—"seedance-2.5"(flagship),"seedance-2.0","seedance-2.0-fast", or"seedance-1.5-pro"prompt— text description of the desired videoratio—"16:9","9:16","4:3","3:4","21:9","1:1", or"adaptive"duration— length in seconds;-1lets the model choose automaticallyresolution—"480p","720p", or"1080p"content— multimodal input array for image-to-video or references, for example{ "type": "image_url", "image_url": { "url": "..." }, "role": "first_frame" }. 包含真人面部的图片必须先走 Portrait:接入后传asset://<asset_id>(见 Portrait guide);真人图片公网 URL 可能因 deepfake / consent 合规被上游拒绝。
查询任务状态
Video generation is asynchronous. Poll for status:
$curl https://api.alltoken.ai/v1/videos/generations/{task_id} -H "Authorization: Bearer $ALLTOKEN_API_KEY"The response includes status (queued, processing, completed, failed, expired, or cancelled) and a download URL when complete.
取消任务
取消 queued 或 processing 中的任务:
$curl -X POST https://api.alltoken.ai/v1/videos/generations/{task_id}/cancel -H "Authorization: Bearer $ALLTOKEN_API_KEY"已经 completed、failed 或 cancelled 的任务不能取消。