> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toapis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling Video O1 視頻生成

> 使用可靈 Kling Video O1 推理增強模型生成最高質量視頻

* 異步處理模式，返回任務 ID 供後續查詢
* **推理增強模型**，生成最高質量視頻
* 使用官方 Omni 引用結構，支持 `image_list`、`video_list`、`element_list`
* 支持標準模式（720P）和專業模式（1080P）
* 支持參考視頻編輯和特徵參考

<Warning>
  請傳入公網可訪問的圖片或視頻 URL。不要直接傳 base64 圖片數據；本地圖片請先使用 [上傳圖片接口](../../uploads/images) 獲取 URL。
</Warning>

## 認證

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用 Bearer Token 進行認證

  獲取 API Key：訪問 [API Key 管理頁面](https://toapis.com/console/token) 獲取您的 API Key

  使用時在請求頭中添加：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## 請求參數

<ParamField body="model" type="string" required>
  視頻生成模型名稱，固定爲 `kling-video-o1`
</ParamField>

<ParamField body="prompt" type="string" required>
  文字提示詞，支持官方 Omni 佔位符，編號從 1 開始：

  * `<<<image_N>>>` 引用 `metadata.image_list`
  * `<<<video_N>>>` 引用 `video_list`
  * `<<<element_N>>>` 引用 `metadata.element_list`

  示例：`"讓<<<image_1>>>中的人物向鏡頭揮手"`

  <Note>
    引用列表順序必須與 prompt 中對應占位符順序一致；系統不會自動補首幀或自動插入佔位符。
  </Note>
</ParamField>

<ParamField body="client_business_id" type="string">
  客戶側業務 ID，例如訂單號、流水號或您系統內的任務 ID。提交後會隨任務保存，後續可用該 ID 查詢狀態：
  `GET /v1/videos/generations/{client_business_id}`。

  也兼容放在 `metadata.client_business_id` 中，但推薦使用頂層字段。
</ParamField>

<ParamField body="mode" type="string" default="std">
  生成模式

  可選值：

  * `std` - 標準模式（720P）
  * `pro` - 專業模式（1080P）

  默認值：`std`
</ParamField>

<ParamField body="duration" type="integer" default="5">
  視頻時長（秒）

  可選值：`3`、`4`、`5`、`6`、`7`、`8`、`9`、`10`

  默認值：`5`
</ParamField>

<ParamField body="aspect_ratio" type="string" default="16:9">
  視頻寬高比

  可選值：

  * `16:9` - 橫屏（默認）
  * `9:16` - 豎屏
  * `1:1` - 方形

  默認值：`16:9`
</ParamField>

<ParamField body="video_list" type="object[]">
  參考視頻列表，最多 1 段視頻

  每個對象包含以下字段：

  <Expandable title="顯示 video_list 對象字段">
    <ParamField body="video_url" type="string" required>
      視頻 URL，必須公開可訪問

      僅支持 MP4/MOV 格式；時長不少於 3 秒；分辨率 720px-2160px；幀率 24-60fps；大小不超過 200MB
    </ParamField>

    <ParamField body="refer_type" type="string" default="base">
      參考類型

      可選值：

      * `base` - 待編輯視頻（默認）
      * `feature` - 特徵參考視頻

      默認值：`base`
    </ParamField>

    <ParamField body="keep_original_sound" type="string" default="no">
      是否保留原視頻聲音

      可選值：

      * `yes` - 保留原聲
      * `no` - 不保留（默認）

      默認值：`no`
    </ParamField>
  </Expandable>

  <Warning>
    * `video_url` 不能爲空，且視頻 URL 需可訪問
    * 當 `refer_type=base` 時：不能定義視頻首尾幀；參考視頻需 3–10 秒；生成視頻時長以上傳視頻爲準
    * 有視頻參考時不要同時開啓 `audio` / `sound`
  </Warning>
</ParamField>

<ParamField body="metadata" type="object">
  擴展參數

  <Expandable title="顯示 metadata 字段">
    <ParamField body="image_list" type="object[]">
      官方 Omni 圖片列表。在 prompt 中通過 `<<<image_1>>>`、`<<<image_2>>>` 按順序引用。

      <Expandable title="顯示 image_list 對象字段">
        <ParamField body="image_url" type="string" required>
          圖片 URL，必須公網可訪問。
        </ParamField>

        <ParamField body="type" type="string">
          圖片類型。首尾幀可傳 `first_frame`、`end_frame`；傳 `end_frame` 時必須同時提供 `first_frame`。
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="element_list" type="object[]">
      官方 Omni 主體/角色引用列表。在 prompt 中通過 `<<<element_1>>>`、`<<<element_2>>>` 按順序引用。

      <Expandable title="顯示 element_list 對象字段">
        <ParamField body="url" type="string" required>
          主體圖片、角色資產或其他官方支持的素材 URL。
        </ParamField>

        <ParamField body="type" type="string">
          元素類型，例如 `image`、`video`。
        </ParamField>

        <ParamField body="role" type="string">
          角色語義，可按官方能力傳入。
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="watermark" type="boolean">
      是否添加水印
    </ParamField>
  </Expandable>
</ParamField>

## Omni 引用語法

Video O1 使用官方 Omni 佔位符引用輸入素材：

| 語法                | 說明                                    |
| ----------------- | ------------------------------------- |
| `<<<image_1>>>`   | 引用 `metadata.image_list` 第 1 張圖片      |
| `<<<video_1>>>`   | 引用 `video_list` 第 1 段視頻               |
| `<<<element_1>>>` | 引用 `metadata.element_list` 第 1 個主體/角色 |

<Warning>
  `image_list`、`video_list`、`element_list` 的順序必須分別與 prompt 中對應占位符的順序一致。
</Warning>

## 響應

<ResponseField name="id" type="string">
  任務唯一標識符，用於查詢任務狀態
</ResponseField>

<ResponseField name="client_business_id" type="string">
  客戶側業務 ID。僅當請求中傳入 `client_business_id` 時返回。
</ResponseField>

<ResponseField name="object" type="string">
  對象類型，固定爲 `generation.task`
</ResponseField>

<ResponseField name="model" type="string">
  使用的模型名稱
</ResponseField>

<ResponseField name="status" type="string">
  任務狀態

  * `queued` - 排隊等待處理
  * `in_progress` - 處理中
  * `completed` - 成功完成
  * `failed` - 失敗
</ResponseField>

<ResponseField name="progress" type="integer">
  任務進度百分比（0-100）
</ResponseField>

<ResponseField name="created_at" type="integer">
  任務創建時間戳（Unix 時間戳）
</ResponseField>

<ResponseField name="metadata" type="object">
  任務元數據
</ResponseField>

## 使用場景

### 場景 1：文生視頻（最高質量）

```json theme={null}
{
  "model": "kling-video-o1",
  "client_business_id": "order_20260428_001",
  "prompt": "黃金時刻的城市天際線，電影質感鏡頭",
  "mode": "pro",
  "duration": 5,
  "aspect_ratio": "16:9"
}
```

### 場景 2：圖片引用（單張）

```json theme={null}
{
  "model": "kling-video-o1",
  "prompt": "讓<<<image_1>>>中的人物向鏡頭揮手",
  "mode": "pro",
  "duration": 5,
  "metadata": {
    "image_list": [
      {
        "image_url": "https://example.com/portrait.jpg"
      }
    ]
  }
}
```

### 場景 3：多圖片引用

```json theme={null}
{
  "model": "kling-video-o1",
  "prompt": "<<<image_1>>>中的角色走向<<<image_2>>>中的場景",
  "mode": "pro",
  "duration": 5,
  "metadata": {
    "image_list": [
      {"image_url": "https://example.com/character.jpg"},
      {"image_url": "https://example.com/scene.jpg"}
    ]
  }
}
```

### 場景 4：參考視頻編輯（video\_list - base）

```json theme={null}
{
  "model": "kling-video-o1",
  "prompt": "將視頻中的背景替換爲海邊日落",
  "video_list": [
    {
      "video_url": "https://example.com/source-video.mp4",
      "refer_type": "base",
      "keep_original_sound": "no"
    }
  ]
}
```

### 場景 5：特徵參考視頻（video\_list - feature）

```json theme={null}
{
  "model": "kling-video-o1",
  "prompt": "<<<element_1>>>中的人物模仿<<<video_1>>>中的動作",
  "video_list": [
    {
      "video_url": "https://example.com/dance-reference.mp4",
      "refer_type": "feature",
      "keep_original_sound": "no"
    }
  ],
  "mode": "std",
  "duration": 5,
  "metadata": {
    "element_list": [
      {
        "url": "https://example.com/character.jpg",
        "type": "image",
        "role": "subject"
      }
    ]
  }
}
```

<Note>
  **查詢任務結果**

  視頻生成爲異步任務，提交後會返回任務 ID。使用 [獲取任務狀態](../../tasks/video-status) 接口查詢生成進度和結果。
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://toapis.com/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "kling-video-o1",
      "prompt": "讓<<<image_1>>>中的人物向鏡頭揮手",
      "mode": "std",
      "duration": 5,
      "aspect_ratio": "16:9",
      "metadata": {
        "image_list": [{"image_url": "https://example.com/portrait.jpg"}]
      }
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://toapis.com/v1/videos/generations",
      headers={
          "Authorization": "Bearer your-ToAPIs-key",
          "Content-Type": "application/json"
      },
      json={
          "model": "kling-video-o1",
          "prompt": "讓<<<image_1>>>中的人物向鏡頭揮手",
          "mode": "std",
          "duration": 5,
          "aspect_ratio": "16:9",
          "metadata": {
              "image_list": [{"image_url": "https://example.com/portrait.jpg"}],
          },
      }
  )

  task = response.json()
  print(f"任務 ID: {task['id']}")
  print(f"狀態: {task['status']}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://toapis.com/v1/videos/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your-ToAPIs-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'kling-video-o1',
      prompt: '讓<<<image_1>>>中的人物向鏡頭揮手',
      mode: 'std',
      duration: 5,
      aspect_ratio: '16:9',
      metadata: {
        image_list: [{ image_url: 'https://example.com/portrait.jpg' }]
      }
    })
  });

  const task = await response.json();
  console.log(`任務 ID: ${task.id}`);
  console.log(`狀態: ${task.status}`);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "video_01J9HA7JPQ9A0Z6JZ3V8M9W6PZ",
    "object": "generation.task",
    "model": "kling-video-o1",
    "status": "queued",
    "progress": 0,
    "created_at": 1768380224,
    "metadata": {}
  }
  ```
</ResponseExample>
