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

# Vidu Q4 Preview 動画生成

> 1 枚の先頭フレーム、または最大 15 枚の参照画像と 3 本の参照音声から動画を生成。3～16 秒、最大 4K、デフォルトで音声付き。

<Info>
  画像から動画生成と参照素材から動画生成に対応します。画像なしのテキスト生成や先頭・末尾フレーム指定には非対応です。送信後、`data[0].task_id` からタスク ID を取得し、[タスク照会](/ja/api-reference/tasks/status)で状態と結果を確認します。
</Info>

## 生成モード

`viduq4-preview` は画像、役割、参照音声からモードを自動選択します。追加のモードパラメータは不要です。

| 入力 | モード |
| - | - |
| `first_frame_image` のみ、または `role: "first_frame"` の画像 1 枚 | 画像から動画 |
| 役割なしの画像 1 枚、参照音声なし | 画像から動画 |
| `reference_image` または `reference` の役割を含み、明示的な先頭フレームなし | 参照素材から動画 |
| 合計 2～15 枚の画像、明示的な先頭フレームなし | 参照素材から動画 |
| 参照音声と 1～15 枚の画像、明示的な先頭フレームなし | 参照素材から動画 |

* **画像から動画**：先頭フレームは 1 枚のみ。プロンプトは任意。参照音声は使用できません。
* **参照素材から動画**：参照画像 1～15 枚、参照音声は最大 3 本。**プロンプト必須**。音声なしで画像 1 枚のみの場合は `role: "reference_image"` を明示してください。未指定だと画像から動画になります。
* 明示的な先頭フレーム（`first_frame_image` または `role: "first_frame"`）と他の画像、参照画像の役割、参照音声は併用できません。併用すると HTTP 400 を返します。

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "viduq4-preview",
      "prompt": "少女が振り返って微笑み、長い髪が風になびく。カメラがゆっくり近づく",
      "image_urls": ["https://example.com/first-frame.png"],
      "duration": 5,
      "resolution": "1080p"
    }'
  ```

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

  response = requests.post(
      "https://api.apimart.ai/v1/videos/generations",
      headers={"Authorization": "Bearer <token>"},
      json={
          "model": "viduq4-preview",
          "prompt": "少女が振り返って微笑み、長い髪が風になびく。カメラがゆっくり近づく",
          "image_urls": ["https://example.com/first-frame.png"],
          "duration": 5,
          "resolution": "1080p"
      }
  )
  response.raise_for_status()
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.apimart.ai/v1/videos/generations", {
    method: "POST",
    headers: {
      Authorization: "Bearer <token>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "viduq4-preview",
      prompt: "少女が振り返って微笑み、長い髪が風になびく。カメラがゆっくり近づく",
      image_urls: ["https://example.com/first-frame.png"],
      duration: 5,
      resolution: "1080p"
    })
  });
  if (!response.ok) throw new Error(await response.text());
  console.log(await response.json());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01K..."
      }
    ]
  }
  ```
</ResponseExample>

## リクエストヘッダー

<ParamField header="Authorization" type="string" required>
  Bearer 認証。形式は `Bearer <token>`。`<token>` は APIMart API Key です。
</ParamField>

## リクエストパラメータ

<ParamField body="model" type="string" required>
  小文字の `viduq4-preview` と完全一致させてください。
</ParamField>

<ParamField body="prompt" type="string">
  動画生成プロンプト。最大 20,000 文字。

  * 画像から動画：任意。省略時は先頭フレームに基づきモデルが内容を生成します。
  * 参照素材から動画：必須。未指定の場合は HTTP 400。
</ParamField>

<ParamField body="image_urls" type="string[]">
  画像配列。公開アクセス可能な画像 URL または `data:image/png;base64,...` などの Base64 Data URL に対応します。

  * 画像から動画：先頭フレームとして 1 枚のみ。
  * 参照素材から動画：`image_with_roles` と合計 1～15 枚。

  `image_with_roles` と併用でき、枚数は合算されます。`first_frame_image` や明示的な `first_frame` 役割とは併用しないでください。役割なしの画像が 1 枚の場合、参照音声の有無もモード選択に影響します。
</ParamField>

<ParamField body="image_with_roles" type="object[]">
  役割付きの画像配列。画像から動画では 1 要素、参照素材から動画では `image_urls` と合計 1～15 枚。

  <Expandable title="画像フィールドを表示">
    <ParamField body="url" type="string" required>
      画像の公開 URL または Base64 Data URL。
    </ParamField>

    <ParamField body="role" type="string">
      画像の役割。大文字・小文字は区別しません：

      * `first_frame`：画像から動画の先頭フレーム。
      * `reference_image`：参照素材から動画の参照画像。`reference` も使用可能。
      * 省略または空：参照音声なしの場合は合計枚数で判断し、1 枚は画像から動画、2 枚以上は参照素材から動画。参照音声ありの場合は参照素材から動画。

      その他の値（`last_frame` など）は同期的に HTTP 400 を返します。
    </ParamField>
  </Expandable>

  `image_urls` と併用して参照画像を指定できますが、先頭フレームの役割と参照素材は混在できません。
</ParamField>

<ParamField body="first_frame_image" type="string">
  画像から動画専用。先頭フレームの公開 URL または Base64 Data URL を指定します。

  このフィールド使用時は他の画像や参照音声を指定しないでください。参照素材から動画では `image_urls` または `image_with_roles` を使用します。
</ParamField>

<ParamField body="audio_urls" type="string[]">
  参照音声 URL 配列。参照素材から動画専用。`audio_url` と合計最大 3 本。

  MP3 形式、各 3～12 秒、各 50MB 以下。参照音声を指定する場合も画像が最低 1 枚必要で、`prompt` は必須です。

  音声の形式や長さが要件に合わない場合、送信時の同期 HTTP 400 ではなく、タスク実行中に失敗し全額返金されます。
</ParamField>

<ParamField body="audio_url" type="string">
  単一の参照音声 URL。要件は `audio_urls` と同じで、両フィールド合計最大 3 本。
</ParamField>

<ParamField body="aspect_ratio" type="string" default="16:9">
  参照素材から動画専用。`1:1`、`9:16`、`16:9`、`3:4`、`4:3` に対応。デフォルトは `16:9`。

  画像から動画では先頭フレームがアスペクト比を決めるため、このパラメータは無視されます。
</ParamField>

<ParamField body="size" type="string">
  `aspect_ratio` の互換フィールドで、同じ値に対応します。どちらか一方だけの使用を推奨します。画像から動画では無効です。
</ParamField>

<ParamField body="duration" type="integer" default="5">
  動画の長さ（秒）。3～16 秒に対応し、1～2 秒は非対応。
</ParamField>

<ParamField body="resolution" type="string" default="720p">
  動画の解像度。`540p`、`720p`、`1080p`、`2K`、`4K` に対応。大文字・小文字は区別しません。
</ParamField>

<ParamField body="audio" type="boolean" default="true">
  会話と効果音を含む動画を出力するかどうか。

  * `true`：音声付き動画（デフォルト）。
  * `false`：無音動画。

  音声の有無で料金は変わりません。
</ParamField>

<ParamField body="seed" type="integer">
  乱数シード。省略または `0` の場合はランダム。
</ParamField>

## 素材の要件

* 画像から動画：先頭フレーム 1 枚が必須。参照音声は使用不可。
* 参照素材から動画：参照画像 1～15 枚が必須。参照音声は任意で最大 3 本。
* PNG、JPEG、JPG、WEBP に対応。画像 1 枚あたり 50MB 以下。
* Base64 使用時はリクエスト全体を 20MB 未満にしてください。公開 URL を推奨します。
* 画像 URL は公開アクセス可能である必要があります。サンプル URL を実際にアクセス可能な画像 URL に置き換えてください。

<Warning>
  両モードとも画像必須で、`last_frame_image` は非対応です。先頭フレームと参照素材の混在や画像・音声数の超過などは送信時に HTTP 400 を返し、タスク作成も課金も行いません。参照音声の形式・長さの不一致は実行中に失敗し返金されます。
</Warning>

## リクエスト例

### 先頭フレームのみ、プロンプトなし

```json theme={null}
{
  "model": "viduq4-preview",
  "image_urls": ["https://example.com/first-frame.png"]
}
```

デフォルトで 5 秒、720p、音声付きの動画を生成します。

### 役割付き先頭フレームと 4K 出力

```json theme={null}
{
  "model": "viduq4-preview",
  "prompt": "カメラがゆっくり近づき、人物が自然に微笑む",
  "image_with_roles": [
    {
      "url": "https://example.com/first-frame.png",
      "role": "first_frame"
    }
  ],
  "duration": 8,
  "resolution": "4K",
  "audio": true
}
```

### 先頭フレームフィールドで無音動画を生成

```json theme={null}
{
  "model": "viduq4-preview",
  "first_frame_image": "https://example.com/first-frame.png",
  "duration": 5,
  "resolution": "1080p",
  "audio": false
}
```

### 複数画像と参照音声で動画を生成

```json theme={null}
{
  "model": "viduq4-preview",
  "prompt": "画像1の少年が参照音声の内容で画像2の少女に話しかけ、背景は画像3のカフェ",
  "image_urls": [
    "https://example.com/boy.png",
    "https://example.com/girl.png",
    "https://example.com/cafe.png"
  ],
  "audio_urls": ["https://example.com/line.mp3"],
  "aspect_ratio": "16:9",
  "duration": 8,
  "resolution": "720p"
}
```

### 画像 1 枚で参照素材から動画を生成

```json theme={null}
{
  "model": "viduq4-preview",
  "prompt": "参照画像の人物がカフェに入り、店員に手を振る",
  "image_with_roles": [
    {
      "url": "https://example.com/person.png",
      "role": "reference_image"
    }
  ],
  "aspect_ratio": "9:16",
  "duration": 5,
  "resolution": "1080p"
}
```

この例は参照音声を指定せず、`reference_image` 役割で参照素材から動画を明示的に選択しています。画像・音声 URL は実際にアクセス可能な素材 URL に置き換えてください。

## 送信レスポンス

<ResponseField name="code" type="integer">
  レスポンスステータスコード。成功時は `200`。
</ResponseField>

<ResponseField name="data" type="array">
  タスク送信結果。

  <Expandable title="タスクフィールドを表示">
    <ResponseField name="status" type="string">
      `submitted` は送信成功を示しますが、動画生成の完了ではありません。
    </ResponseField>

    <ResponseField name="task_id" type="string">
      状態と結果の照会に使用するタスク ID。
    </ResponseField>
  </Expandable>
</ResponseField>

## タスク結果の照会

5～10 秒間隔でポーリングし、`completed` または `failed` で停止してください。統一照会エンドポイントを使用します：

```bash theme={null}
curl --request GET \
  --url https://api.apimart.ai/v1/tasks/task_01K... \
  --header 'Authorization: Bearer <token>'
```

成功レスポンス例（動画 URL はプレースホルダー）：

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01K...",
    "status": "completed",
    "progress": 100,
    "result": {
      "videos": [
        {
          "url": ["https://example.com/generated-video.mp4"]
        }
      ]
    }
  }
}
```

| 状態 | 対応 |
| - | - |
| `pending` | 待機中。ポーリングを継続 |
| `processing` | 生成中。ポーリングを継続 |
| `completed` | 成功。`data.result.videos[0].url` 配列から動画リンクを取得 |
| `failed` | 失敗。`data.error.message` で原因を確認しポーリング停止。全額返金 |

動画リンクの有効期限は 24 時間です。早めにダウンロードして保存してください。完了判定は固定の進捗値ではなく `status` に基づいてください。

## 料金

動画の長さと解像度で課金：料金 = 長さ（秒）× 解像度別の秒単価。

具体的な料金は[モデル料金](https://apimart.ai/pricing)をご確認ください。画像から動画と参照素材から動画は同額で、音声の有無でも変わりません。参照画像・参照音声の追加料金はなく、失敗したタスクは自動で全額返金されます。

## よくあるパラメータエラー

以下は同期的に HTTP 400 を返し、タスク作成も課金も行いません：

| 問題 | 対応 |
| - | - |
| 画像なし | 画像から動画では先頭フレーム 1 枚、参照素材から動画では参照画像 1～15 枚を指定 |
| 明示的な先頭フレームと他の画像、参照役割、参照音声を混在 | 画像から動画では先頭フレーム 1 枚のみ残し、参照素材から動画では明示的な先頭フレームフィールド・役割を削除 |
| `last_frame` など未対応の `role` | `first_frame`、`reference_image`、`reference`、または空を使用 |
| 参照画像が 15 枚超 | `image_urls` と `image_with_roles` の合計を 15 枚以下にする |
| 参照音声が 3 本超 | `audio_urls` と `audio_url` の合計を 3 本以下にする |
| 参照素材から動画で `prompt` が未指定 | 最大 20,000 文字のプロンプトを追加 |
| `21:9` など未対応の参照動画アスペクト比 | `1:1`、`9:16`、`16:9`、`3:4`、`4:3` を使用 |
| `last_frame_image` を指定 | 削除してください。先頭・末尾フレーム指定は非対応 |
| `duration` が 3 未満または 16 超 | 3～16 秒の整数を使用 |
| `480p`、`8K` など未対応の解像度 | `540p`、`720p`、`1080p`、`2K`、`4K` を使用 |

## その他の Vidu モデル

テキストから動画や先頭・末尾フレーム指定には [Vidu Q3 Pro / Turbo](/ja/api-reference/videos/vidu-q3-pro/generation) を使用してください。本モデルは複数参照画像に対応済みです。[Vidu Q3 Mix / Standard](/ja/api-reference/videos/vidu-q3/generation) の参照生成機能も参照できます。1～2 秒の動画には `viduq3-pro` を選択してください。本モデルは最低 3 秒です。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.