# 视频生成 API

如何通过 /videos 生成视频：发起任务、轮询状态、下载文件。请求字段、参考文件、草稿以及视频如何计费。

## Video

视频模型以任务方式运行。POST /videos 发起任务并立即返回其 id；每隔几秒轮询 GET /videos/{id}，直到 status 变为 completed 或 failed（通常需要 1 到 5 分钟），然后下载：完成的任务带有 url（文件链接，有效期一周，每次读取都会续期；如果我们未能存储该文件，url 则为路径 /v1/videos/{id}/content），而 GET /videos/{id}/content 始终可以获取文件。联系支持时，请提供任意响应中的 id（chatcmpl-…、img_…、video_…）或任意错误中的 request_id。

| 字段 | 类型 |  |
| --- | --- | --- |
| `model` | string | 必填。视频模型 id。 |
| `prompt` | string | 必填（使用 draft_id 时除外）。3 到 20,000 个字符。 |
| `seconds` | integer \| "auto" | 时长（duration 视为同一字段）。Seedance 2.5：4 到 30；Seedance 2.0：4 到 15。"auto" 由模型自行选择；按最长时长预扣，按实际生成的时长付费。默认 5；使用 reference_videos 时默认为 "auto"。 |
| `resolution` | string | 480p、720p（默认）、1080p 或 4k；仅限模型提供的分辨率（见模型参考）。 |
| `ratio` | string | 16:9（默认）、9:16、1:1、4:3、3:4、21:9 或 adaptive。使用 reference_videos 时默认跟随输入视频。 |
| `image` | string | 首帧：图像链接或 data URL（first_frame 视为同一字段）。 |
| `last_frame` | string | 尾帧，与 image 一起使用。 |
| `audio` | boolean | 随视频生成声音。默认 true。 |
| `seed` | integer | -1 表示随机 seed（默认），或填写 1 到 4294967295 之间的整数，以便在同一模型上复现结果。返回结果会显示你发送的 seed，随机时为 -1。 |
| `camera_fixed` | boolean | 为 true 时镜头保持不动。 |
| `bitrate_mode` | string | standard（默认）或 high。模型繁忙时 high 可能失败；失败时会退款。 |
| `return_last_frame` | boolean | 为 true 时，最后一帧会以图像形式保存在 GET /videos/{id}/last_frame。 |
| `real_person_mode` | boolean | Seedance 2.5：允许参考照片和视频中出现真人。默认开启；设为 false 可关闭。 |
| `reference_images` | string[] | 图像链接或 data URL：Seedance 2.5 最多 30 张，Seedance 2.0 最多 9 张（jpeg、png、webp、bmp、tiff、gif；最大 30 MB；每边 300 到 6000 px）。 |
| `reference_videos` | string[] | 公开的 MP4/MOV 链接：Seedance 2.5 最多 10 个，Seedance 2.0 最多 3 个；每个 2 到 15 秒，480p 或 720p，最大 50 MB。其时长也会计费。 |
| `reference_audios` | string[] | 公开的 WAV/MP3 链接：Seedance 2.5 最多 10 个，Seedance 2.0 最多 3 个；每个 2 到 15 秒，最大 15 MB。 |
| `task_type` | string | 与 reference_videos 一起使用：auto、reference、edit 或 extend（Seedance 2.5）。edit 和 extend 跟随输入视频；不要发送 seconds 和 ratio。 |
| `draft` | boolean | Seedance 2.5：为 true 时以 480p 的价格生成 480p 预览。resolution 必须为 480p。 |
| `draft_id` | string | 将已完成的草稿生成为最终的 1080p 视频。只需发送 model 和 draft_id：提示词、参考文件、时长、比例、音频和 seed 都取自草稿。草稿保留 7 天。 |

参考文件按类型、依发送顺序编号：reference_images 的第一项是图像 1，第二项是图像 2，视频和音频同理。在提示词中也按这种方式称呼它们，就像 playground 使用 [Image 1]、[Video 1] 和 [Audio 1] 一样，例如 "The woman in [Image 1] walks through the street of [Video 1]"。发送的文件超过模型上限时，请求会被拒绝，而不会被截断。

status 为 queued、in_progress、completed 或 failed。已完成的任务包含 usage.video_tokens 和 usage.cost_usd；失败的任务不收费，并包含 error.code 和 error.message：generation_failed（模型未能生成视频）、invalid_reference（某个参考文件被拒绝；消息会指明是哪个）、output_audio_copyright、output_video_copyright、real_person_in_input、ratio_with_frame、camera_fixed_not_available、task_type_mismatch（请求或其结果被拒绝；消息会说明需要修改什么）、upstream_rate_limited（所有供应商都繁忙，任务等待 30 秒后仍是如此；请在一分钟后重新发起）或 timeout。

```
// GET https://api.apistore.cloud/v1/videos/video_...
{
  "id": "video_0123456789abcdef0123456789abcdef",
  "object": "video",
  "model": "MODEL_NAME",
  "status": "completed",
  "created_at": 1793984023,
  "completed_at": 1793984214,
  "prompt": "A red paper boat drifting across a calm lake at sunrise",
  "resolution": "720p",
  "ratio": "16:9",
  "seconds": 5,
  "draft": false,
  "seed": 49873,
  "url": "https://.../video_0123456789abcdef0123456789abcdef.mp4",
  "last_frame": null,
  "error": null,
  "usage": { "video_tokens": 108000, "cost_usd": 1.0978 }
}
```

草稿（Seedance 2.5）：先生成低价的 480p 预览，再把满意的那一版以相同的 seed 和设置转为最终的 1080p 视频。

```
# 1. the draft: 480p, at the 480p price
curl https://api.apistore.cloud/v1/videos -H "Authorization: Bearer sk-..." -H "Content-Type: application/json" \
  -d '{"model": "MODEL_NAME", "prompt": "A red paper boat on a lake", "seconds": 5, "resolution": "480p", "draft": true}'

# 2. when it is completed, the final video at 1080p
curl https://api.apistore.cloud/v1/videos -H "Authorization: Bearer sk-..." -H "Content-Type: application/json" \
  -d '{"model": "MODEL_NAME", "draft_id": "video_..."}'
```

任务开始时，会从余额中预扣预估费用：按所选分辨率的价格，计算（输入视频秒数 + 输出秒数）对应的视频 token。任务完成后按实际生成的 token 付费（720p 下 5 秒约 108K），其余部分退回；失败的任务不收费。你可以在「设置」中把视频计费方式从 token 价目表切换为 “按 usd”：即供应商对该任务按标价收取的费用，减去你的折扣。每条计费记录都会注明采用的方式。

## 模型指南

各视频模型系列的擅长之处、限制，以及如何写出模型能准确遵循的提示词。

### Seedance 2.5

长视频模型：单个任务最长 30 秒，支持大量参考文件，并可编辑或延长现有视频。它能书写和说 11 种语言，其中包括越南语和英语。

| 概览 |  |
| --- | --- |
| **时长** | 4 到 30 秒，或 "auto" 由模型自行选择 |
| **分辨率** | 480p、720p、1080p |
| **比例** | 21:9、16:9、4:3、1:1、3:4、9:16 或 adaptive（跟随输入） |
| **模式** | 文生视频；首帧，或首尾帧；参考生成；编辑视频；延长视频 |
| **参考文件** | 最多 30 张图像、10 个视频和 10 个音频。可以只发送音频 |
| **声音** | 语音、音乐和音效与画面一同生成（audio: true） |
| **草稿** | 支持：先生成 480p 预览，再从满意的那一版生成最终视频 |

**编写提示词**

- **先写一句话.** 用一行写清谁、在哪里、发生了什么、风格和镜头。然后在下面补充细节。
- **绑定每个参考文件.** 用编号指代每个文件，并说明它的用途："[Image 1] is the lead actress, [Image 2] is the cafe, follow the camera of [Video 1]"。不要依靠图片里写的文字来说明某人是谁。
- **长视频用时间轴.** 把故事分成连续、无间隔的整秒区间（"0-5 s"、"5-12 s"）或编号镜头，并为每段写明画面、镜头、动作、台词和声音。每段内容太少，模型会自由发挥；太多，则会切得过于频繁。
- **主体数量要少.** 一到五个主体效果最稳定。五个主体以内，可以为同一主体提供多个视角作为参考；超过五个，每个主体只发送一个视角。
- **编辑（task_type: edit）.** 说明改什么、在哪里改、从什么改成什么；如果只改一部分，写明秒数："In [Video 1], from second 4 to 6 she waves instead of nodding; everything else stays"。结果保留输入视频的时长和比例，因此不要发送 seconds 和 ratio。20 秒以内的视频编辑效果最好。
- **延长（task_type: extend）.** 说明延长方向和接下来发生的事："Extend [Video 1] forward: she opens the door and walks into the rain"。比例跟随输入视频。
- **首帧和尾帧.** 以相同的宽高比通过 image 和 last_frame 发送，视频就会准确地从首帧开始、在尾帧结束。如果只是在提示词中把某张参考图称为 "the first frame"，遵循程度会较弱。
- **故事板和关键帧.** 故事板（不超过 15 格、简单线稿、不含文字）可以引导剧情，但不会逐格遵循。如需严格的画面，请发送单独的图像，并以 "Use Images 1 to 5 in order as keyframes" 开头。
- **镜头.** 常见的影视术语可直接使用：push in、pan、tracking shot、orbit、handheld、low angle、long take。生僻术语请用几个词解释，并说明转场在何时发生以及如何发生。
- **不想要的内容.** 描述你想要什么，而不是不想要什么。有两个例外效果很好："No subtitles" 和 "No background music, only ambient sound"。
- **台词.** 台词按以下格式书写：名字、括号中的情绪，然后是台词内容。每句台词只用一种语言。需要在画面上准确拼写的文字，请以图像形式发送。

**提示词示例**

```
[Image 1] is the fisherman, [Image 2] is his boat. Documentary style, natural light.
0-6 s: wide shot at water level, the boat drifts through morning mist. Slow push in.
6-14 s: medium shot, he pulls the net in, hand over hand. Water drips from the rope.
14-20 s: close-up on his face as he looks at the catch and smiles.
Ambient sound only: water, wood, gulls. No subtitles, no background music.
```

### Seedance 2.0

三个接受相同请求的模型，在质量、速度和价格上各有不同：Seedance 2.0 画质最佳，Seedance 2.0 fast 兼顾速度和成本，Seedance 2.0 mini 价格最低。

| 概览 |  |
| --- | --- |
| **时长** | 4 到 15 秒，或 "auto" |
| **分辨率** | Seedance 2.0：480p、720p、1080p、4K。Fast 和 mini：480p、720p |
| **比例** | 21:9、16:9、4:3、1:1、3:4、9:16 |
| **模式** | 文生视频；首帧，或首尾帧；参考生成；通过提示词编辑或延长视频 |
| **参考文件** | 最多 9 张图像、3 个视频和 3 个音频。音频必须搭配图像或视频 |
| **声音** | 语音、音乐和音效与画面一同生成（audio: true） |
| **草稿** | 不支持 |
| **4K 文件** | H.265 编码，10 位色深。部分播放器无法打开；VLC 以及当前版本的 Chrome、Edge 和 Safari 可以 |
| **人脸** | 含有真人面部的参考图像和视频会被拒绝 |

**编写提示词**

- **公式.** 主体、动作、地点、光线与色彩、镜头、风格、画质，最后是要避免的内容。先确定谁做什么，再确定在哪里，最后确定怎么拍。
- **每个主体只定义一次.** 给出两三个固定特征（服装、发型、体型）和一个称呼，之后始终使用同一称呼："The girl in the red coat from [Image 1]"。
- **写镜头，不写秒数.** 为镜头编号："Shot 1: ... Shot 2: ..."，每个镜头写明运镜、动作、地点和声音。该模型无法可靠地遵循 "0-3 s" 这类精确时间。
- **每个镜头一种运镜.** Push in、pan 或 track 三选一。在一个镜头中组合多种运镜会使结果不稳定。
- **用身体动作描述运动.** 写明身体部位、幅度和速度。缓慢、连续的动作效果最好。通过身体表现情绪（"lowers her head, eyes reddening"），而不是直接说出情绪。
- **少用参考文件.** 四五个就够了：一两个用于角色，一个用于场景，一个视频用于运镜，一个音频用于氛围。参考中超过四个人会降低稳定性，也不建议为同一个人提供多个视角。
- **保持面部稳定.** 发送一张头部特写和一张全身图，并说明哪张用于面部、哪张用于服装。把最重要的文件放在最前面。
- **编辑.** 直接指明视频并说明要改什么："Strictly edit [Video 1]: replace the cat with the lion from [Image 1], keep everything else"。这里不要写 "reference [Video 1]"，否则它只会被当作参考。
- **延长.** "Extend [Video 1] forward" 或 "backward"，然后写接下来发生的事。可以将两到三个片段用转场连接起来，总长 15 秒。加上 "end with [Video 1]" 可在结果中保留原始画面。
- **台词和文字.** 把台词放在花括号中，并始终使用同一种语言：She says {We are late}。对于画面中的文字，写明文字内容以及出现的时间、位置和方式。请使用常见字符。
- **要避免的内容.** 字幕和 logo 仍可能出现。"Keep it subtitle-free" 和 "Do not generate a logo or watermark" 可以减少它们；去掉参考文件中的文字也有帮助。

**提示词示例**

```
[Image 1] is the girl in the red coat, [Image 2] is the night market. Follow the camera of [Video 1].
Shot 1: wide shot, she walks in between the stalls. Slow push in.
Shot 2: medium shot, she stops at a lantern stall and lifts one lantern. Fixed camera.
Shot 3: close-up, warm light on her face. She says {This one}.
Cinematic, warm tones, rich detail. Keep it subtitle-free. Do not generate a logo or watermark.
```

---

Source: https://apistore.cloud/zh/docs/video
