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

# 動画生成インターフェース

>  AiHubMix は統一された動画生成 API を提供し、OpenAI Sora のインターフェース形式と互換性があり、バックエンドで複数ベンダーのモデルをサポートします

## クイックスタート

動画生成は非同期処理であり、全体のフローは3つのステップに分かれます：

```text theme={null}
1. タスクを送信 → video_id を取得
2. ステータスをポーリング → status が completed になるまで待機
3. 動画をダウンロード → MP4 ファイルを取得
```

**最小サンプル**

```shellscript theme={null}
# ステップ1：動画生成タスクを送信
curl -X POST https://aihubmix.com/v1/videos \
  -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.6-t2v",
    "prompt": "A cat playing jazz on a piano, warm lighting, cinematic shot",
    "seconds": "5",
    "size": "1280x720"
  }'

# レスポンス例：
# {
#   "id": "eyJtb2RlbCI6IndhbjI...",
#   "object": "video",
#   "status": "in_progress",
#   "model": "wan2.6-t2v",
#   "duration": 5,
#   "width": 1280,
#   "height": 720,
#   ...
# }

# ステップ2：ステータスをポーリング（15 秒ごとに照会し、status が completed になるまで）
curl https://aihubmix.com/v1/videos/{video_id} \
  -H "Authorization: Bearer $AIHUBMIX_API_KEY"

# ステップ3：動画をダウンロード
curl https://aihubmix.com/v1/videos/{video_id}/content \
  -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
  --output video.mp4
```

## インターフェース概要

| インターフェース | メソッド   | パス                              | 説明                  |
| :------- | :----- | :------------------------------ | :------------------ |
| 動画作成     | POST   | `/v1/videos`                    | 動画生成タスクを送信          |
| ステータス照会  | GET    | `/v1/videos/{video_id}`         | タスクのステータスと進捗を照会     |
| 動画ダウンロード | GET    | `/v1/videos/{video_id}/content` | 生成された MP4 動画をダウンロード |
| タスク削除    | DELETE | `/v1/videos/{video_id}`         | 動画タスクを削除            |

Base URL：`https://aihubmix.com`

認証方式：Bearer Token

```shellscript theme={null}
Authorization: Bearer $AIHUBMIX_API_KEY
```

## サポートされているモデル

### テキストから動画（Text-to-Video）

| ベンダー      | モデル名                                                    | 特徴                                                |
| --------- | ------------------------------------------------------- | ------------------------------------------------- |
| OpenAI    | `sora-2`                                                | 標準的な動画生成、音声と映像の同期をサポート                            |
| OpenAI    | `sora-2-pro`                                            | 高品質版、より精緻で安定した映像                                  |
| Google    | `veo-3.1-generate-preview`                              | 最新の Veo 3.1、ネイティブ音声、4K をサポート                      |
| Google    | `veo-3.1-fast-generate-preview`                         | Veo 3.1 高速版、生成速度がより速い                             |
| Google    | `veo-3.0-generate-preview`                              | Veo 3.0、高忠実度の動画                                   |
| Google    | `veo-2.0-generate-001`                                  | Veo 2.0、安定版                                       |
| Alibaba   | `wan2.6-t2v`                                            | Tongyi Wanxiang 最新版、音声と映像の同期                      |
| Alibaba   | `wan2.5-t2v-preview`                                    | Tongyi Wanxiang 2.5、中国語最適化                        |
| Alibaba   | `wan2.2-t2v-plus`                                       | Tongyi Wanxiang 2.2                               |
| ByteDance | `jimeng-3.0-pro`                                        | Jimeng 3.0 Pro、1080P 高画質                          |
| ByteDance | `jimeng-3.0-1080p`                                      | Jimeng 3.0 1080P                                  |
| ByteDance | `doubao-seedance-2-0-260128`                            | プロ級のマルチモーダル創作動画モデル Seedance 2.0                   |
| ByteDance | `doubao-seedance-2-0-fast-260128`                       | Seedance 2.0 高速版                                  |
| Kuaishou  | `kling-v3`、`kling-v2-6`、`kling-v2-5-turbo`、`kling-v2-1` | Kling テキスト/画像から動画、新版は 3\~15 秒をサポート                |
| Kuaishou  | `kling-v3-omni`、`kling-video-o1`                        | Kling OmniVideo マルチモーダル、参考動画・ネイティブ音声・マルチショットをサポート |

### 画像から動画（Image-to-Video）

| ベンダー      | モデル名                              | 特徴                                      |
| --------- | --------------------------------- | --------------------------------------- |
| Alibaba   | `wan2.6-i2v`                      | Tongyi Wanxiang 最新版の画像から動画              |
| Alibaba   | `wan2.5-i2v-preview`              | Tongyi Wanxiang 2.5 画像から動画              |
| Alibaba   | `wan2.2-i2v-plus`                 | Tongyi Wanxiang 2.2 画像から動画              |
| ByteDance | `doubao-seedance-2-0-260128`      | マルチモーダル参考入力、画像/動画/音声をサポート               |
| ByteDance | `doubao-seedance-2-0-fast-260128` | Seedance 2.0 高速版                        |
| Kuaishou  | `kling-v1-6` など                   | Kling 画像から動画、末尾フレーム・複数画像参照（最大 4 枚）をサポート |

<Note>
  画像から動画では `input_reference` パラメータで参考画像を渡す必要があります（Alibaba Tongyi Wanxiang）；Doubao Seedance は `extra_body.content` 配列で渡し、画像・動画・音声など複数の参照タイプをサポートします；Kling は `image` / `image_tail` / `image_list` で画像を渡します。詳しくは下記の [Kling](#kling) セクションを参照してください。
</Note>

## API 詳細説明

### リクエストヘッダー

```shellscript theme={null}
Authorization: Bearer $AIHUBMIX_API_KEY
Content-Type: application/json
```

### 動画生成タスクの作成

```shellscript theme={null}
POST /v1/videos
```

#### **リクエストボディ**

| パラメータ             | 型             | 必須  | 説明                                             |
| :---------------- | :------------ | :-- | :--------------------------------------------- |
| `model`           | string        | はい  | モデル名、例：`wan2.6-t2v`、`sora-2`                   |
| `prompt`          | string        | はい  | 動画の説明テキスト                                      |
| `seconds`         | string        | いいえ | 動画の長さ（秒）、統一して文字列型を使用、例：`"5"`、`"8"`（各モデルの詳細を参照） |
| `size`            | string        | いいえ | 解像度、形式は `幅x高さ`、例：`1920x1080`（モデルごとにサポート値が異なる）  |
| `input_reference` | string/object | いいえ | 参考画像（画像から動画）、URL または base64 をサポート              |

> モデルによってレスポンス形式に若干の違いがありますが、いずれも `id`（video\_id）と `status` フィールドを含みます。`status` でタスクの進捗を判断すればよいです。

#### レスポンス例（**Tongyi Wanxiang/Veo/Jimeng AI**）

```json theme={null}
{
  "id": "eyJtb2RlbCI6IndhbjI...",
  "object": "video",
  "created": 1772460274,
  "model": "wan2.6-t2v",
  "status": "in_progress",
  "prompt": "A cat watching the rain on a windowsill",
  "duration": 5,
  "width": 1920,
  "height": 1080,
  "url": null,
  "error": null
}
```

**レスポンス例（Sora）**

```json theme={null}
{
  "id": "eyJtb2RlbCI6InNvcmEtMi...",
  "object": "video",
  "created_at": 1772451930,
  "status": "queued",
  "model": "sora-2",
  "progress": 0,
  "prompt": "A cinematic drone shot over mountains",
  "seconds": "8",
  "size": "1280x720"
}
```

#### 共通ステータス値の説明

| ステータス         | 説明            |
| :------------ | :------------ |
| `queued`      | 待機中（Sora 固有）  |
| `in_progress` | 生成中           |
| `completed`   | 生成完了、ダウンロード可能 |
| `failed`      | 生成失敗          |

### 動画ステータスの照会

```shellscript theme={null}
GET /v1/videos/{video_id}
```

このインターフェースをポーリングしてタスクが完了したか確認します。**15 秒** ごとに照会することを推奨します。

#### **レスポンス例（生成完了 - Tongyi Wanxiang）**

```json theme={null}
{
  "id": "eyJtb2RlbCI6IndhbjI...",
  "object": "video",
  "status": "completed",
  "model": "wan2.5-t2v-preview",
  "duration": 5,
  "width": 1920,
  "height": 1080,
  "url": "https://aihubmix.com/v1/videos/eyJtb2RlbCI6IndhbjI.../content",
  "error": null
}
```

#### **レスポンス例（生成完了 - Sora）**

```json theme={null}
{
  "id": "eyJtb2RlbCI6InNvcmEtMi...",
  "object": "video",
  "created_at": 1772451930,
  "status": "completed",
  "completed_at": 1772452114,
  "expires_at": 1772538330,
  "model": "sora-2",
  "progress": 100,
  "prompt": "A cinematic drone shot over mountains",
  "seconds": "8",
  "size": "1280x720"
}
```

> すべてのモデルは `status == "completed"` で完了状態を判断し、その後 `/content` インターフェースを呼び出してダウンロードします。

### 動画コンテンツのダウンロード

```shellscript theme={null}
GET /v1/videos/{video_id}/content
```

ステータスが `completed` になったら、このインターフェースを呼び出して MP4 動画ファイルをダウンロードします。

**レスポンス**: 動画のバイナリストリームを直接返します（`Content-Type: video/mp4`）。

```shellscript theme={null}
curl https://aihubmix.com/v1/videos/{video_id}/content \
  -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
  --output my_video.mp4
```

> **注意**：動画のダウンロードリンクは通常 24 時間の有効期限があります。速やかにダウンロードして保存してください。

### 動画タスクの削除

このインターフェースは作成済みの動画タスクを削除するために使用します。

```shellscript theme={null}
DELETE /v1/videos/{video_id}
```

## 各モデルのパラメータ詳細

### **OpenAI Sora**

| パラメータ        | サポート値                                                |
| ------------ | ---------------------------------------------------- |
| モデル          | `sora-2`、`sora-2-pro`                                |
| 長さ (seconds) | `"4"`（デフォルト）、`"8"`、`"12"`                            |
| 解像度 (size)   | `720x1280`（デフォルト）、`1280x720`、`1024x1792`、`1792x1024` |
| 画像から動画       | サポート、`input_reference` で画像を渡す                        |

> ヒント：すべてのモデルの `seconds` パラメータは統一して文字列型で渡します（例：`"8"`）。

**サンプル**

<CodeGroup>
  ```shellscript Sora theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "sora-2",
      "prompt": "A cinematic drone shot soaring over a misty mountain range at sunrise, golden light filtering through the clouds",
      "seconds": "8",
      "size": "1280x720"
    }'
  ```

  ```shellscript Sora Pro 縦型動画 theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "sora-2-pro",
      "prompt": "A person walking through a neon-lit city street at night, rain reflecting on the pavement, cinematic lighting",
      "seconds": "12",
      "size": "720x1280"
    }'
  ```
</CodeGroup>

### Google Veo

| パラメータ            | サポート値                                                                                                                                                                                                                                                                                      |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| モデル              | `veo-3.1-generate-preview`（推奨）、`veo-3.1-fast-generate-preview`（高速）、`veo-3.0-generate-preview`、`veo-2.0-generate-001`                                                                                                                                                                       |
| 長さ (seconds)     | Veo 3/3.1：`"4"`、`"6"`、`"8"`；Veo 2：`"5"`\~`"8"`（デフォルト `"8"`）                                                                                                                                                                                                                                |
| 解像度 (size)       | `720p`（デフォルト）、`1080p`、`4k`（4K は Veo 3+ のみ）、またはピクセル形式 `1280x720`、`1920x1080`                                                                                                                                                                                                                |
| アスペクト比           | 16:9（デフォルト）、9:16                                                                                                                                                                                                                                                                           |
| 画像から動画 (Veo 3.1) | **先頭フレーム**：`first_frame`（または互換フィールド `input_reference`）；**末尾フレーム**：`last_frame`；**参照画像**：`reference_images`（配列、最大 3 枚）。画像には公開 URL、base64 データ URL、または `{"mime_type": "...", "data": "..."}` オブジェクトを指定できます。**長さ**：先頭フレーム／先頭・末尾フレームは `"4"`／`"6"`／`"8"` をサポート；参照画像を使用する場合、Google は出力を 8 秒に固定します |

**サンプル**

<CodeGroup>
  ```shellscript Veo 3.1 theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "veo-3.1-generate-preview",
      "prompt": "A tranquil Japanese garden, cherry blossom petals slowly drifting down, koi swimming in the pond, with the melodious sound of wind chimes in the background",
      "seconds": "8",
      "size": "1280x720"
    }'
  ```

  ```shellscript Veo 3.1 Fast theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "veo-3.1-fast-generate-preview",
      "prompt": "Ocean waves crashing on rocky cliffs at sunset, seagulls flying overhead",
      "seconds": "8",
      "size": "1280x720"
    }'
  ```

  ```shellscript 先頭・末尾フレーム theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "veo-3.1-generate-preview",
      "prompt": "The camera slowly pushes in from a valley at dawn, transitioning naturally into sunset",
      "seconds": "8",
      "size": "1280x720",
      "first_frame": "https://example.com/first.jpg",
      "last_frame": "https://example.com/last.jpg"
    }'
  ```

  ```shellscript 参照画像（最大 3 枚） theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "veo-3.1-generate-preview",
      "prompt": "The character from the reference images walks through a forest, cinematic shot",
      "seconds": "8",
      "size": "1280x720",
      "reference_images": [
        "https://example.com/ref1.jpg",
        "https://example.com/ref2.jpg"
      ]
    }'
  ```
</CodeGroup>

<Note>
  **画像フィールドに関する注意**：

  * 先頭フレームの優先順位：`first_frame` > `input_reference`（OpenAI 互換の単一フレーム）。
  * `first_frame` / `last_frame` / `reference_images` の各要素には、公開 URL、base64 データ URL（`data:image/png;base64,...`）、または `{"mime_type":"image/png","data":"<base64>"}` オブジェクトを指定できます。
  * OpenRouter 形式の `frame_images`（`frame_type: first_frame | last_frame` を持つ要素）および `input_references` エイリアスも受け付けます。
  * 参照画像は最大 3 枚まで；これを超えると 400 を返します。
</Note>

> ヒント：Veo はネイティブ音声生成をサポートしており、prompt 内で効果音を記述できます。例：「背景に鳥のさえずりが聞こえる」「ピアノの旋律」。

### Tongyi Wanxiang

| パラメータ        | サポート値                                                        |
| ------------ | ------------------------------------------------------------ |
| テキストから動画モデル  | `wan2.6-t2v`（推奨）、`wan2.5-t2v-preview`、`wan2.2-t2v-plus`      |
| 画像から動画モデル    | `wan2.6-i2v`（推奨）、`wan2.5-i2v-preview`、`wan2.2-i2v-plus`      |
| 長さ (seconds) | モデルによって異なる（下記の説明を参照）、デフォルト `"5"`                             |
| 解像度 (size)   | 下記の表を参照、`x` と `*` の区切り文字どちらも可（例：`1920x1080` または `1920*1080`） |
| 画像から動画       | `input_reference` で画像 URL または base64 を渡す                     |

**各モデルがサポートする長さ**

| モデル                                         | seconds 選択可能値         | デフォルト値 |
| :------------------------------------------ | :-------------------- | :----- |
| `wan2.6-t2v` / `wan2.6-i2v`                 | `"2"`\~`"15"`（任意の整数値） | `"5"`  |
| `wan2.5-t2v-preview` / `wan2.5-i2v-preview` | `"5"` または `"10"`      | `"5"`  |
| `wan2.2-t2v-plus` / `wan2.2-i2v-plus`       | `"5"`（固定）             | `"5"`  |

**サポートされる解像度（幅\*高さ）**

| 画質    | 選択可能な解像度                                                               |
| :---- | :--------------------------------------------------------------------- |
| 480P  | `832x480`、`480x832`、`624x624`                                          |
| 720P  | `1280x720`（デフォルト）、`720x1280`、`960x960`、`1088x832`（4:3）、`832x1088`（3:4） |
| 1080P | `1920x1080`、`1080x1920`、`1440x1440`、`1632x1248`（4:3）、`1248x1632`（3:4）  |

> **注意**：wan2.6 は 720P と 1080P のみサポート；wan2.5 は 480P、720P、1080P をサポート；wan2.2 は 480P と 1080P のみサポート。

**サンプル**

<CodeGroup>
  ```shellscript テキストから動画 theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "wan2.6-t2v",
      "prompt": "A winding stream flows through an autumn forest, golden fallen leaves drifting on the water surface, sunlight casting dappled light and shadow through the leaves",
      "seconds": "5",
      "size": "1920x1080"
    }'
  ```

  ```shellscript 画像から動画 theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "wan2.6-i2v",
      "prompt": "The character in the frame slowly turns their head and smiles, the camera slowly pushes in",
      "seconds": "5",
      "size": "1280x720",
      "input_reference": "https://example.com/my-image.jpg"
    }'
  ```
</CodeGroup>

> ヒント：wan2.5 以上のバージョンはデフォルトで音声付き動画を生成します（自動吹き替え）。中国語の prompt の方が効果が高いです。

### Jimeng AI

| パラメータ        | サポート値                                         |
| ------------ | --------------------------------------------- |
| モデル          | `jimeng-3.0-pro`（推奨）、`jimeng-3.0-1080p`       |
| 長さ (seconds) | `"5"` または `"10"`（デフォルト `"5"`）                 |
| 解像度 (size)   | アスペクト比形式またはピクセル形式をサポート                        |
| 画像から動画       | サポート、`input_reference` で画像 URL または base64 を渡す |

**サポートされるアスペクト比と対応する解像度**

| アスペクト比 (size)          | 実際の解像度    |
| :--------------------- | :-------- |
| `16:9` または `1920x1080` | 1920×1088 |
| `9:16` または `1080x1920` | 1088×1920 |
| `4:3` または `1664x1248`  | 1664×1248 |
| `3:4` または `1248x1664`  | 1248×1664 |
| `1:1` または `1440x1440`  | 1440×1440 |
| `21:9` または `2176x928`  | 2176×928  |

**サンプル**

<CodeGroup>
  ```shellscript Jimeng AI theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "jimeng-3.0-pro",
      "prompt": "A young woman in Hanfu dances gracefully amid a bamboo forest, her long dress flowing in the wind, with a faint morning mist in the background",
      "seconds": "5",
      "size": "16:9"
    }'
  ```

  ```Jimeng AI 縦画面版 theme={null}
  curl -X POST https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "jimeng-3.0-1080p",
      "prompt": "A sunset over the ocean, waves gently rolling, warm golden light",
      "seconds": "5",
      "size": "9:16"
    }'
  ```
</CodeGroup>

### Doubao Seedance

| パラメータ                    | サポート値                                                                       |
| ------------------------ | --------------------------------------------------------------------------- |
| モデル                      | `doubao-seedance-2-0-260128`、`doubao-seedance-2-0-fast-260128`              |
| 解像度 (resolution)         | `"480p"`、`"720p"`（デフォルト）                                                    |
| 長さ (duration)            | 整数、範囲 `4`\~`15`、または `-1`（モデルが自動決定）                                          |
| アスペクト比 (ratio)           | `"adaptive"`（デフォルト、自動適応）、`"16:9"`、`"9:16"`、`"1:1"`、`"4:3"`、`"3:4"`、`"21:9"` |
| 音声付き動画 (generate\_audio) | デフォルト `true`；`false` に設定すると無音動画を生成                                          |
| ウォーターマーク (watermark)     | デフォルト `false`                                                               |
| マルチモーダル参照                | 画像・動画・音声をサポート                                                               |

**`extra_body.content` がサポートする参照タイプ**

| タイプ  | `type` 値    | `role` 値          | 説明            |
| ---- | ----------- | ----------------- | ------------- |
| 参考画像 | `image_url` | `reference_image` | 画面/スタイル参考画像   |
| 参考動画 | `video_url` | `reference_video` | カメラワーク/構図参考動画 |
| 参考音声 | `audio_url` | `reference_audio` | BGM 音声ファイル    |

**サンプル**

```shellscript Seedance 2.0 / 2.0 Fast theme={null}
curl -X POST "https://aihubmix.com/v1/videos" \
  -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedance-2-0-260128",
    "prompt": "Use the first-person POV framing from Video 1 throughout, and use Audio 1 as the background music for the entire clip. Create a first-person fruit tea commercial featuring the Seedance brand limited-edition apple fruit tea, "Ping Ping An An." 

Opening frame: Image 1. From a first-person perspective, your hand picks a dew-covered Aksu red apple, accompanied by a crisp, satisfying bite-like tapping sound.

Seconds 2–4: Fast-paced cuts. Your hand drops freshly cut apple chunks into a shaker, adds ice and tea base, then shakes vigorously. The sound of ice clinking and shaking syncs with upbeat percussion. Background voiceover: "Freshly cut, freshly shaken."

Seconds 4–6: First-person close-up of the finished drink. The layered fruit tea is poured into a clear cup. Your hand gently squeezes a creamy topping across the surface. A pink label is placed on the cup. The camera pushes in to highlight the rich texture and layering.

Seconds 6–8: First-person hand holding the drink. You raise the fruit tea from Image 2 toward the camera, as if offering it directly to the viewer. The label is clearly visible. Background voiceover: "Take a refreshing sip."

Final frame: Freeze on Image 2. 

All background voiceovers should be in a female voice.",
    "extra_body": {
      "content": [
        {
          "type": "image_url",
          "image_url": {
            "url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/r2v_tea_pic1.jpg"
          },
          "role": "reference_image"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/r2v_tea_pic2.jpg"
          },
          "role": "reference_image"
        },
        {
          "type": "video_url",
          "video_url": {
            "url": "https://ark-project.tos-cn-beijing.volces.com/doc_video/r2v_tea_video1.mp4"
          },
          "role": "reference_video"
        },
        {
          "type": "audio_url",
          "audio_url": {
            "url": "https://ark-project.tos-cn-beijing.volces.com/doc_audio/r2v_tea_audio1.mp3"
          },
          "role": "reference_audio"
        }
      ],
      "ratio": "16:9",
      "duration": 11,
      "watermark": false
    }
  }'
```

### Kling

Kling は **テキストから動画、画像から動画、複数画像参照から動画、OmniVideo マルチモーダル** の4種類の機能をサポートし、統一して `/v1/videos` インターフェース経由で呼び出します。ゲートウェイが「モデル名 + 入力形態」に応じて Kling 対応エンドポイントへ自動ルーティングするため、呼び出し側で区別する必要はありません。

| 機能                | モデル                                                                                          |
| ----------------- | -------------------------------------------------------------------------------------------- |
| テキストから / 画像から     | `kling-v1`、`kling-v1-5`、`kling-v1-6`、`kling-v2-1`、`kling-v2-5-turbo`、`kling-v2-6`、`kling-v3` |
| 複数画像参照            | `kling-v1-6`                                                                                 |
| OmniVideo マルチモーダル | `kling-video-o1`、`kling-v3-omni`                                                             |

**パラメータ**

| パラメータ                  | 型      | 説明                                                                                                                |
| ---------------------- | ------ | ----------------------------------------------------------------------------------------------------------------- |
| `model`                | string | **必須**、`kling-*`、機能とバージョンを決定                                                                                      |
| `prompt`               | string | テキストプロンプト                                                                                                         |
| `negative_prompt`      | string | ネガティブプロンプト                                                                                                        |
| `mode`                 | string | 生成モード：`std`（720P）/ `pro`（1080P）/ `4k`、デフォルト `std`                                                                 |
| `duration` / `seconds` | string | 長さ（秒）、旧モデル `5`/`10`、新モデル `3`\~`15`、デフォルト `5`                                                                      |
| `aspect_ratio`         | string | 画角：`16:9` / `9:16` / `1:1`（omni のテキストのみ生成・動画参照時は必須、未指定時は自動的に `16:9` を補完）                                          |
| `cfg_scale`            | float  | プロンプト関連性 `[0, 1]`、デフォルト `0.5`（`kling-v2.x` はサポートしない）                                                              |
| `image`                | string | **画像から**：単一画像、画像 URL または Base64（Base64 は `data:image/...;base64,` プレフィックスを含まない）                                   |
| `image_tail`           | string | **画像から**：末尾フレーム画像（オプション）                                                                                          |
| `image_list`           | array  | **複数画像参照**：画像 URL の配列、最大 4 枚                                                                                      |
| `sound`                | string | **omni**：`on`/`off`、ネイティブ音声を生成するか、デフォルト `off`                                                                     |
| `video_list`           | array  | **omni**：参考動画 `[{ "video_url": "...", "refer_type": "feature" }]`、`refer_type` は `feature`（動画参照）/ `base`（動画編集）を取る |

<Note>
  サポートされていない、またはマッピングされていない重要なパラメータは明示的にエラーを返し、サイレントに破棄されることはありません。その他の Kling ネイティブパラメータは `extra_body` に入れて上流へパススルーできます。
</Note>

**サンプル**

<CodeGroup>
  ```shellscript テキストから動画 theme={null}
  curl https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "kling-v1-6",
      "prompt": "An orange cat running on a sunlit grassy meadow",
      "mode": "std",
      "duration": "5"
    }'
  ```

  ```shellscript 画像から動画 theme={null}
  curl https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "kling-v1-6",
      "image": "https://example.com/first.png",
      "prompt": "The camera pulls back, the character smiles",
      "mode": "std",
      "duration": "5"
    }'
  ```

  ```shellscript 複数画像参照 theme={null}
  curl https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "kling-v1-6",
      "image_list": ["https://example.com/a.png", "https://example.com/b.png"],
      "prompt": "Two characters meet on the street",
      "mode": "std",
      "duration": "5"
    }'
  ```

  ```shellscript OmniVideo 参考動画 theme={null}
  curl https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "kling-v3-omni",
      "prompt": "Generate the next shot based on the reference video",
      "video_list": [{ "video_url": "https://example.com/in.mp4", "refer_type": "feature" }],
      "mode": "std",
      "duration": "5"
    }'
  ```

  ```shellscript OmniVideo ネイティブ音声 theme={null}
  curl https://aihubmix.com/v1/videos \
    -H "Authorization: Bearer $AIHUBMIX_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "kling-v3-omni",
      "prompt": "A man smiles and says hello",
      "sound": "on",
      "aspect_ratio": "16:9",
      "duration": "5"
    }'
  ```
</CodeGroup>

**説明**

* **非同期3ステップ**：送信して `video_id` を取得 → `GET /v1/videos/{video_id}` をポーリングして `status` が `completed` になるまで待つ → `GET /v1/videos/{video_id}/content` で MP4 をダウンロード。ステータス値：`in_progress` / `completed` / `failed`。
* 動画の出力は通常 1\~3 分；結果動画 URL は **30 日後にクリーンアップ** されるため、速やかに転送保存してください。
* **タスク削除**：Kling には削除インターフェースがなく、`DELETE /v1/videos/{video_id}` は `501 not_supported` を返します。
* **課金**：モデル × `mode` × 長さ × 機能（参考動画の有無 / 音声の有無）に応じて課金；**生成失敗時は課金されません**、照会とダウンロードは課金対象外です。

## **完全な呼び出しサンプル**

<CodeGroup>
  ```python Tongyi Wanxiang theme={null}
  import requests
  import time

  API_KEY = "AIHUBMIX_API_KEY"
  BASE_URL = "https://aihubmix.com"
  HEADERS = {
      "Authorization": f"Bearer {API_KEY}",
      "Content-Type": "application/json"
  }

  # ステップ1：動画生成タスクを作成
  response = requests.post(
      f"{BASE_URL}/v1/videos",
      headers=HEADERS,
      json={
          "model": "wan2.6-t2v",
          "prompt": "A desert under a starry sky, a meteor streaking across the night sky, the glow of a distant campfire flickering in the breeze",
          "seconds": "5",
          "size": "1920x1080"
      }
  )
  result = response.json()
  video_id = result["id"]
  print(f"タスクが作成されました、video_id: {video_id}")

  # ステップ2：ステータスをポーリング
  while True:
      status_response = requests.get(
          f"{BASE_URL}/v1/videos/{video_id}",
          headers=HEADERS
      )
      status_data = status_response.json()
      current_status = status_data["status"]
      print(f"現在のステータス: {current_status}")

      if current_status == "completed":
          print("動画生成完了！")
          break
      elif current_status == "failed":
          error_msg = status_data.get("error", {})
          if isinstance(error_msg, dict):
              error_msg = error_msg.get("message", "不明なエラー")
          print(f"生成失敗: {error_msg}")
          break

      time.sleep(15)  # 15 秒ごとに照会

  # ステップ3：動画をダウンロード
  video_response = requests.get(
      f"{BASE_URL}/v1/videos/{video_id}/content",
      headers=HEADERS
  )
  with open("output.mp4", "wb") as f:
      f.write(video_response.content)
  print(f"動画を output.mp4 として保存しました（{len(video_response.content) / 1024 / 1024:.1f} MB）")
  ```

  ```python Sora theme={null}
  import requests
  import time

  API_KEY = "AIHUBMIX_API_KEY"
  BASE_URL = "https://aihubmix.com"
  HEADERS = {
      "Authorization": f"Bearer {API_KEY}",
      "Content-Type": "application/json"
  }

  # 動画生成タスクを作成
  response = requests.post(
      f"{BASE_URL}/v1/videos",
      headers=HEADERS,
      json={
          "model": "sora-2",
          "prompt": "A cinematic shot of a futuristic city at sunset, flying cars in the background",
          "seconds": "8",       # "4"/"8"/"12" から選択可
          "size": "1280x720"    # 1280x720, 720x1280, 1024x1792, 1792x1024 をサポート
      }
  )
  result = response.json()
  video_id = result["id"]
  print(f"タスクが作成されました、video_id: {video_id}")

  # Sora のステータスポーリング（queued -> in_progress -> completed の可能性あり）
  while True:
      status_response = requests.get(
          f"{BASE_URL}/v1/videos/{video_id}",
          headers=HEADERS
      )
      status_data = status_response.json()
      current_status = status_data["status"]
      progress = status_data.get("progress", "")
      print(f"ステータス: {current_status}, 進捗: {progress}%")

      if current_status == "completed":
          print("動画生成完了！")
          break
      elif current_status == "failed":
          print(f"生成失敗: {status_data.get('error')}")
          break

      time.sleep(15)

  # 動画をダウンロード
  video_response = requests.get(
      f"{BASE_URL}/v1/videos/{video_id}/content",
      headers=HEADERS
  )
  with open("sora_output.mp4", "wb") as f:
      f.write(video_response.content)
  print("動画を sora_output.mp4 として保存しました")
  ```

  ```javascript Node.js theme={null}
  const API_KEY = "your_aihubmix_api_key";
  const BASE_URL = "https://aihubmix.com";

  async function generateVideo() {
    // ステップ1：タスクを作成（Veo 3.1 を例に）
    const createResponse = await fetch(`${BASE_URL}/v1/videos`, {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${API_KEY}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        model: "veo-3.1-generate-preview",
        prompt: "A desert under a starry sky, with a meteor streaking across the night.",
        seconds: "8",
        size: "1280x720"
      })
    });
    const { id: videoId } = await createResponse.json();
    console.log(`タスクが作成されました: ${videoId}`);

    // ステップ2：ステータスをポーリング
    let status = "in_progress";
    while (status !== "completed" && status !== "failed") {
      await new Promise(resolve => setTimeout(resolve, 15000));
      const statusResponse = await fetch(`${BASE_URL}/v1/videos/${videoId}`, {
        headers: { "Authorization": `Bearer ${API_KEY}` }
      });
      const result = await statusResponse.json();
      status = result.status;
      console.log(`現在のステータス: ${status}`);
    }

    if (status === "completed") {
      // ステップ3：動画をダウンロード
      const videoResponse = await fetch(`${BASE_URL}/v1/videos/${videoId}/content`, {
        headers: { "Authorization": `Bearer ${API_KEY}` }
      });
      const fs = require("fs");
      const buffer = Buffer.from(await videoResponse.arrayBuffer());
      fs.writeFileSync("output.mp4", buffer);
      console.log("動画を output.mp4 として保存しました");
    }
  }

  generateVideo();
  ```
</CodeGroup>

## **FAQ**

### **動画生成にはどのくらい時間がかかりますか？**

動画生成は通常 1-5 分かかり、具体的な時間はモデル、解像度、長さによって異なります。15 秒のポーリング間隔を設定することを推奨します。

### `input_reference` **パラメータはどう使いますか？**

`input_reference` は画像から動画のシナリオで使用し、3種類の渡し方をサポートします：

```json theme={null}
// 方法1：画像 URL を直接渡す
"input_reference": "https://example.com/image.jpg"

// 方法2：base64 エンコードされた画像を渡す（オブジェクト形式）
"input_reference": {
  "mime_type": "image/jpeg",
  "data": "<BASE64_ENCODED_IMAGE>"
}

// 方法3：data URL を渡す
"input_reference": "data:image/jpeg;base64,<BASE64_ENCODED_IMAGE>"
```

### **動画ダウンロードリンクの有効期限はどのくらいですか？**

生成された動画のダウンロードリンクは通常 **24 時間** の有効期限があります。速やかにダウンロードして保存してください。

### **各モデルの**`seconds` **パラメータにはどんな違いがありますか？**

| モデル                                                 | 選択可能値                         | デフォルト値 |
| --------------------------------------------------- | ----------------------------- | ------ |
| Sora (`sora-2` / `sora-2-pro`)                      | `"4"`, `"8"`, `"12"`          | `"4"`  |
| Veo 3/3.1 (`veo-3.1-generate-preview` など)           | `"4"`, `"6"`, `"8"`           | `"8"`  |
| Veo 2 (`veo-2.0-generate-001`)                      | `"5"`\~`"8"`                  | `"8"`  |
| Tongyi Wanxiang `wan2.6`                            | `"2"`\~`"15"`                 | `"5"`  |
| Tongyi Wanxiang `wan2.5`                            | `"5"`, `"10"`                 | `"5"`  |
| Tongyi Wanxiang `wan2.2`                            | `"5"`（固定）                     | `"5"`  |
| Jimeng AI (`jimeng-3.0-pro` など)                     | `"5"`, `"10"`                 | `"5"`  |
| Doubao Seedance (`doubao-seedance-2-0-*`)           | 整数 `duration4`\~`15` または `-1` | `5`    |
| Kling 新版 (`kling-v2-x` / `kling-v3` など)             | `"3"`\~`"15"`                 | `"5"`  |
| Kling 旧版 (`kling-v1` / `kling-v1-5` / `kling-v1-6`) | `"5"`, `"10"`                 | `"5"`  |

\> **ヒント**：すべてのモデルの `seconds` パラメータは統一して文字列型で渡します（例：`"8"`）。API が自動的に処理します。

### モデルによって`size` パラメータの形式にはどんな違いがありますか？

| モデル             | サポートされる size 値                                                                              |
| --------------- | ------------------------------------------------------------------------------------------- |
| Sora            | `1280x720720x12801024x17921792x1024`                                                        |
| Veo             | ピクセル形式（`1280x720` など）または解像度ラベル（`720p1080p4k`）                                               |
| Tongyi Wanxiang | ピクセル形式、`x` と `*` どちらも可（例：`1920x1080` または `1920*1080`）                                       |
| Jimeng AI       | アスペクト比形式（`16:99:16` など）またはピクセル形式                                                            |
| Doubao Seedance | アスペクト比形式（`"adaptive"`、`"16:9"`、`"9:16"` など）                                                 |
| Kling           | `size` を使用せず、`mode`（`std`/`pro`/`4k` で画質を制御）+ `aspect_ratio`（`16:9`/`9:16`/`1:1` で画角を制御）を使用 |

**###** `seconds` **と** `duration` **にはどんな違いがありますか？**

両者の意味は同じで、どちらも動画の長さを表します。API はこの両方のパラメータ名をサポートしています（Sora を除く。Sora は `seconds` のみ受け付けます）。統一して `seconds` を使用することを推奨します。

### より良い prompt を書くには？

* **具体的なシーンを描写する**：主体、動作、環境、光線、雰囲気を含める
* **カメラの言語を指定する**：例「クローズアップ」「空撮」「ズームイン」「スローモーション」
* **スタイルを描写する**：例「映画的」「ドキュメンタリー風」「アニメ風」
* **中国語モデルには中国語 prompt の方が効果的**：Tongyi Wanxiang は中国語に最適化されている
* **Veo は音声記述をサポート**：prompt 内で音を記述できる、例「鳥のさえずり」「ピアノの旋律」

### タスクが失敗した場合の対処は？

`status` が `failed` の場合、レスポンスの `error` フィールドにエラー情報が含まれます：

```json theme={null}
{
  "status": "failed",
  "error": {
    "message": "Video generation failed due to content policy violation",
    "type": "video_generation_error"
  }
}
```

## よくある失敗原因には、コンテンツ違反、prompt が長すぎる、画像形式が非対応などがあります。エラー情報に基づいて調整してから再試行してください。

最終更新：2026-06-01
