> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 创建视频生成

POST https://api.elevenlabs.io/v1/flows/video
Content-Type: application/json

使用所选模型启动视频生成。

Reference: https://elevenlabs.io/docs/api-reference/flows/video/create

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Body (application/json)

This endpoint expects a VideoGenerationRequest.

- `VideoGenerationRequest`
  - `model_id`: `bytedance-seedance-v2` (BytedanceSeedance2Request)
    - `prompt` (string, required) — 要生成视频的文本描述。
    - `aspect_ratio` (enum, optional, default: 16:9) — 输出视频的宽高比。使用 `auto` 时，模型会根据输入选择宽高比。
      - Allowed values: `auto`, `21:9`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16`
    - `audios` (list of AudioReference, optional) — 最多 3 段参考音频，例如用于口型同步。至少需要提供 `images` 或 `videos` 之一，且不能与 `start_frame`/`end_frame` 一起使用。
    - `duration_secs` (integer, optional, default: 5) — 输出视频时长，单位为秒。
    - `end_frame` (ImageReference, optional, nullable) — 用作视频末帧的图像。
    - `generate_audio` (boolean, optional, default: true) — 是否随视频生成音频。
    - `images` (list of ImageReference, optional) — 最多 9 张用于参考主体的图片。不能与 `start_frame`/`end_frame` 一起使用。
    - `resolution` (enum, optional, default: 720p) — 输出视频的分辨率。
      - Allowed values: `480p`, `720p`, `1080p`, `4k`
    - `seed` (integer, optional, nullable) — 用于可复现生成的种子：相同种子和输入在多次生成中会产生相似输出。省略则随机生成。
    - `start_frame` (ImageReference, optional, nullable) — 用作视频首帧的图像。
    - `videos` (list of VideoReference, optional) — 最多 3 个用于参考主体或动作的视频。不能与 `start_frame`/`end_frame` 一起使用。
    - `webhook` (WebhookTarget, optional, nullable) — 包含此项后，生成完成或失败时会将结果发送到工作区配置的 flows webhook。webhook 负载与相应 GET 端点的最终响应一致。
  - `model_id`: `bytedance-seedance-v2-fast` (BytedanceSeedance2FastRequest)
    - `prompt` (string, required) — 要生成视频的文本描述。
    - `aspect_ratio` (enum, optional, default: 16:9) — 输出视频的宽高比。使用 `auto` 时，模型会根据输入选择宽高比。
      - Allowed values: `auto`, `21:9`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16`
    - `audios` (list of AudioReference, optional) — 最多 3 段参考音频，例如用于口型同步。至少需要提供 `images` 或 `videos` 之一，且不能与 `start_frame`/`end_frame` 一起使用。
    - `duration_secs` (integer, optional, default: 5) — 输出视频时长，单位为秒。
    - `end_frame` (ImageReference, optional, nullable) — 用作视频末帧的图像。
    - `generate_audio` (boolean, optional, default: true) — 是否随视频生成音频。
    - `images` (list of ImageReference, optional) — 最多 9 张用于参考主体的图片。不能与 `start_frame`/`end_frame` 一起使用。
    - `resolution` (enum, optional, default: 720p) — 输出视频的分辨率。
      - Allowed values: `480p`, `720p`
    - `seed` (integer, optional, nullable) — 用于可复现生成的种子：相同种子和输入在多次生成中会产生相似输出。省略则随机生成。
    - `start_frame` (ImageReference, optional, nullable) — 用作视频首帧的图像。
    - `videos` (list of VideoReference, optional) — 最多 3 个用于参考主体或动作的视频。不能与 `start_frame`/`end_frame` 一起使用。
    - `webhook` (WebhookTarget, optional, nullable) — 包含此项后，生成完成或失败时会将结果发送到工作区配置的 flows webhook。webhook 负载与相应 GET 端点的最终响应一致。
  - `model_id`: `bytedance-seedance-v2-mini` (BytedanceSeedance2MiniRequest)
    - `prompt` (string, required) — 要生成视频的文本描述。
    - `aspect_ratio` (enum, optional, default: 16:9) — 输出视频的宽高比。使用 `auto` 时，模型会根据输入选择宽高比。
      - Allowed values: `auto`, `21:9`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16`
    - `audios` (list of AudioReference, optional) — 最多 3 段参考音频，例如用于口型同步。至少需要提供 `images` 或 `videos` 之一，且不能与 `start_frame`/`end_frame` 一起使用。
    - `duration_secs` (integer, optional, default: 5) — 输出视频时长，单位为秒。
    - `end_frame` (ImageReference, optional, nullable) — 用作视频末帧的图像。
    - `generate_audio` (boolean, optional, default: true) — 是否随视频生成音频。
    - `images` (list of ImageReference, optional) — 最多 9 张用于参考主体的图片。不能与 `start_frame`/`end_frame` 一起使用。
    - `resolution` (enum, optional, default: 720p) — 输出视频的分辨率。
      - Allowed values: `480p`, `720p`
    - `seed` (integer, optional, nullable) — 用于可复现生成的种子：相同种子和输入在多次生成中会产生相似输出。省略则随机生成。
    - `start_frame` (ImageReference, optional, nullable) — 用作视频首帧的图像。
    - `videos` (list of VideoReference, optional) — 最多 3 个用于参考主体或动作的视频。不能与 `start_frame`/`end_frame` 一起使用。
    - `webhook` (WebhookTarget, optional, nullable) — 包含此项后，生成完成或失败时会将结果发送到工作区配置的 flows webhook。webhook 负载与相应 GET 端点的最终响应一致。
  - `model_id`: `bytedance-seedance-v2.5` (BytedanceSeedance25Request)
    - `prompt` (string, required) — 要生成视频的文本描述。
    - `aspect_ratio` (enum, optional, default: 16:9) — 输出视频的宽高比。使用 `auto` 时，模型会根据输入选择宽高比。首帧任务和首尾帧任务始终使用 `auto`。
      - Allowed values: `auto`, `21:9`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16`
    - `audios` (list of AudioReference, optional) — 最多 10 段参考音频，例如用于口型同步。不能与 `start_frame`/`end_frame` 一起使用。
    - `duration_secs` (integer, optional, default: 5) — 输出视频时长，单位为秒。
    - `end_frame` (ImageReference, optional, nullable) — 用作视频末帧的图像。
    - `generate_audio` (boolean, optional, default: true) — 是否随视频生成音频。
    - `images` (list of ImageReference, optional) — 最多 30 张用于参考主体的图片。不能与 `start_frame`/`end_frame` 一起使用。
    - `resolution` (enum, optional, default: 720p) — 输出视频的分辨率。
      - Allowed values: `480p`, `720p`, `1080p`
    - `start_frame` (ImageReference, optional, nullable) — 用作视频首帧的图像。
    - `videos` (list of VideoReference, optional) — 最多 10 个用于参考主体或动作的视频。不能与 `start_frame`/`end_frame` 一起使用。
    - `webhook` (WebhookTarget, optional, nullable) — 包含此项后，生成完成或失败时会将结果发送到工作区配置的 flows webhook。webhook 负载与相应 GET 端点的最终响应一致。
  - `model_id`: `creatify-aurora` (CreatifyAuroraRequest)
    - `audio` (AudioReference, required) — 用于驱动角色唇部动作的语音音频。
    - `image` (ImageReference, required) — 要制作动画的角色图像。
    - `audio_guidance_scale` (double, optional, nullable) — 唇部动作遵循音频的强度。省略则使用模型默认值。
    - `guidance_scale` (double, optional, nullable) — 生成结果遵循输入图像的强度。省略则使用模型默认值。
    - `resolution` (enum, optional, default: 720p) — 输出视频的分辨率。
      - Allowed values: `480p`, `720p`
    - `webhook` (WebhookTarget, optional, nullable) — 包含此项后，生成完成或失败时会将结果发送到工作区配置的 flows webhook。webhook 负载与相应 GET 端点的最终响应一致。
  - `model_id`: `veo-3.1-fast-generate-001` (Veo3_1FastRequest)
    - `prompt` (string, required) — 要生成视频的文本描述。
    - `aspect_ratio` (enum, optional, default: 16:9) — 输出视频的宽高比。
      - Allowed values: `16:9`, `9:16`
    - `duration_secs` (enum, optional, default: 8) — 输出视频时长，单位为秒。
      - Allowed values: `4`, `6`, `8`
    - `end_frame` (ImageReference, optional, nullable) — 用作视频末帧的图像。
    - `enhance_prompt` (boolean, optional, default: true) — 模型是否可重写提示词以改善结果。
    - `generate_audio` (boolean, optional, default: true) — 是否随视频生成音频。
    - `images` (list of VeoImageReference, optional) — 最多 3 张用于参考主体或风格的图片。不能与 `start_frame`/`end_frame` 一起使用，且时长必须为 8 秒。
    - `negative_prompt` (string, optional, nullable) — 视频应避免包含内容的文本描述。
    - `resolution` (enum, optional, default: 720p) — 输出视频的分辨率。
      - Allowed values: `720p`, `1080p`, `4K`
    - `seed` (integer, optional, nullable) — 用于可复现生成的种子：相同种子和输入在多次生成中会产生相似输出。省略则随机生成。
    - `start_frame` (ImageReference, optional, nullable) — 用作视频首帧的图像。
    - `webhook` (WebhookTarget, optional, nullable) — 包含此项后，生成完成或失败时会将结果发送到工作区配置的 flows webhook。webhook 负载与相应 GET 端点的最终响应一致。
  - `model_id`: `veo-3.1-generate-001` (Veo3_1Request)
    - `prompt` (string, required) — 要生成视频的文本描述。
    - `aspect_ratio` (enum, optional, default: 16:9) — 输出视频的宽高比。
      - Allowed values: `16:9`, `9:16`
    - `duration_secs` (enum, optional, default: 8) — 输出视频时长，单位为秒。
      - Allowed values: `4`, `6`, `8`
    - `end_frame` (ImageReference, optional, nullable) — 用作视频末帧的图像。
    - `enhance_prompt` (boolean, optional, default: true) — 模型是否可重写提示词以改善结果。
    - `generate_audio` (boolean, optional, default: true) — 是否随视频生成音频。
    - `images` (list of VeoImageReference, optional) — 最多 3 张用于参考主体或风格的图片。不能与 `start_frame`/`end_frame` 一起使用，且时长必须为 8 秒。
    - `negative_prompt` (string, optional, nullable) — 视频应避免包含内容的文本描述。
    - `resolution` (enum, optional, default: 720p) — 输出视频的分辨率。
      - Allowed values: `720p`, `1080p`, `4K`
    - `seed` (integer, optional, nullable) — 用于可复现生成的种子：相同种子和输入在多次生成中会产生相似输出。省略则随机生成。
    - `start_frame` (ImageReference, optional, nullable) — 用作视频首帧的图像。
    - `webhook` (WebhookTarget, optional, nullable) — 包含此项后，生成完成或失败时会将结果发送到工作区配置的 flows webhook。webhook 负载与相应 GET 端点的最终响应一致。

## Response

### 200

成功响应

- `id` (string, required) — 生成任务的唯一标识符。将其传入相应的 GET 端点以获取输出。
- `status` ("pending", required) — 新创建的生成任务始终为 `pending`。

## Errors

### 422 Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### AudioReference

- `type`: `asset` (StaticAssetReference)
  - `asset_id` (string, required) — 通过 assets API（`POST /v1/assets`）上传的资源 ID，即该响应中返回的 `asset_id`。
- `type`: `generation` (GenerationReference)
  - `generation_id` (string, required) — 要使用其输出的生成记录 ID，在创建生成记录时返回。
- `type`: `inline_base64` (InlineAudioReference)
  - `content_base64` (string, required) — 媒体文件的字节数据，采用 base64 编码（标准字母表）。解码后最大 25MB。
  - `mime_type` (enum, required) — 编码音频的 MIME 类型。
    - Allowed values: `audio/mpeg`, `audio/wav`

### ImageReference

- `type`: `asset` (StaticAssetReference)
  - `asset_id` (string, required) — 通过 assets API（`POST /v1/assets`）上传的资源 ID，即该响应中返回的 `asset_id`。
- `type`: `generation` (GenerationReference)
  - `generation_id` (string, required) — 要使用其输出的生成记录 ID，在创建生成记录时返回。
- `type`: `inline_base64` (InlineImageReference)
  - `content_base64` (string, required) — 媒体文件的字节数据，采用 base64 编码（标准字母表）。解码后最大 25MB。
  - `mime_type` (enum, required) — 编码图像的 MIME 类型。
    - Allowed values: `image/jpeg`, `image/png`, `image/webp`, `image/heic`, `image/heif`

### VideoReference

- `type`: `asset` (StaticAssetReference)
  - `asset_id` (string, required) — 通过 assets API（`POST /v1/assets`）上传的资源 ID，即该响应中返回的 `asset_id`。
- `type`: `generation` (GenerationReference)
  - `generation_id` (string, required) — 要使用其输出的生成记录 ID，在创建生成记录时返回。
- `type`: `inline_base64` (InlineVideoReference)
  - `content_base64` (string, required) — 媒体文件的字节数据，采用 base64 编码（标准字母表）。解码后最大 25MB。
  - `mime_type` (enum, required) — 编码视频的 MIME 类型。
    - Allowed values: `video/mp4`, `video/quicktime`, `video/webm`

### WebhookTarget

- `type`: `all` (WebhookTargetAll)
- `type`: `ids` (WebhookTargetIds)
  - `ids` (list of string, required) — 用于接收结果的工作区 flows webhook ID。每个 ID 都必须是工作区已配置的 flows webhook。

### VeoImageReference

用于引导 Veo 生成的参考图片及其角色。

- `image` (ImageReference, required) — 参考图像。
- `role` (enum, required) — 模型使用图像的方式：`subject` 将其主体或场景元素放入视频；`style` 迁移其视觉风格。
  - Allowed values: `subject`, `style`

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

- string
- integer

## Examples

**Request**

```json
{
  "audio": {
    "generation_id": "JWr5N6X9ZTqf8jD2LmQb",
    "type": "string"
  },
  "image": {
    "generation_id": "JWr5N6X9ZTqf8jD2LmQb",
    "type": "string"
  },
  "model_id": "string"
}
```

**Response**

```json
{
  "id": "JWr5N6X9ZTqf8jD2LmQb",
  "status": "pending"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/flows/video"

payload = {
    "audio": {
        "generation_id": "JWr5N6X9ZTqf8jD2LmQb",
        "type": "string"
    },
    "image": {
        "generation_id": "JWr5N6X9ZTqf8jD2LmQb",
        "type": "string"
    },
    "model_id": "string"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/flows/video';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"audio":{"generation_id":"JWr5N6X9ZTqf8jD2LmQb","type":"string"},"image":{"generation_id":"JWr5N6X9ZTqf8jD2LmQb","type":"string"},"model_id":"string"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/flows/video"

	payload := strings.NewReader("{\n  \"audio\": {\n    \"generation_id\": \"JWr5N6X9ZTqf8jD2LmQb\",\n    \"type\": \"string\"\n  },\n  \"image\": {\n    \"generation_id\": \"JWr5N6X9ZTqf8jD2LmQb\",\n    \"type\": \"string\"\n  },\n  \"model_id\": \"string\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/flows/video")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"audio\": {\n    \"generation_id\": \"JWr5N6X9ZTqf8jD2LmQb\",\n    \"type\": \"string\"\n  },\n  \"image\": {\n    \"generation_id\": \"JWr5N6X9ZTqf8jD2LmQb\",\n    \"type\": \"string\"\n  },\n  \"model_id\": \"string\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.elevenlabs.io/v1/flows/video")
  .header("Content-Type", "application/json")
  .body("{\n  \"audio\": {\n    \"generation_id\": \"JWr5N6X9ZTqf8jD2LmQb\",\n    \"type\": \"string\"\n  },\n  \"image\": {\n    \"generation_id\": \"JWr5N6X9ZTqf8jD2LmQb\",\n    \"type\": \"string\"\n  },\n  \"model_id\": \"string\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.elevenlabs.io/v1/flows/video', [
  'body' => '{
  "audio": {
    "generation_id": "JWr5N6X9ZTqf8jD2LmQb",
    "type": "string"
  },
  "image": {
    "generation_id": "JWr5N6X9ZTqf8jD2LmQb",
    "type": "string"
  },
  "model_id": "string"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/flows/video");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"audio\": {\n    \"generation_id\": \"JWr5N6X9ZTqf8jD2LmQb\",\n    \"type\": \"string\"\n  },\n  \"image\": {\n    \"generation_id\": \"JWr5N6X9ZTqf8jD2LmQb\",\n    \"type\": \"string\"\n  },\n  \"model_id\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "audio": [
    "generation_id": "JWr5N6X9ZTqf8jD2LmQb",
    "type": "string"
  ],
  "image": [
    "generation_id": "JWr5N6X9ZTqf8jD2LmQb",
    "type": "string"
  ],
  "model_id": "string"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/flows/video")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```