> ## 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.

# Wan3.0 動画生成

>  - アリババクラウド万相 3.0 オールインワン参照動画モデル（統一エンドポイント）
- テキストから動画 / 先頭フレーム / 先頭・最終フレーム / マルチモーダル参照 / ファイル・Web 参照
- 解像度 480P / 720P / 1080P、長さ 2–30 秒
- 画像、動画、音声、ドキュメント、公開 Web ページを参照として利用可能 

<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": "wan3.0-video",
      "prompt": "子猫が月明かりの屋根を駆け抜け、遠くで街のネオンが瞬く。映画級の画質、滑らかなカメラワーク。",
      "resolution": "720P",
      "size": "16:9",
      "duration": 5
    }'
  ```

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

  url = "https://api.apimart.ai/v1/videos/generations"

  payload = {
      "model": "wan3.0-video",
      "prompt": "子猫が月明かりの屋根を駆け抜け、遠くで街のネオンが瞬く。映画級の画質、滑らかなカメラワーク。",
      "resolution": "720P",
      "size": "16:9",
      "duration": 5,
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json",
  }

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

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.apimart.ai/v1/videos/generations";

  const payload = {
    model: "wan3.0-video",
    prompt: "子猫が月明かりの屋根を駆け抜け、遠くで街のネオンが瞬く。映画級の画質、滑らかなカメラワーク。",
    resolution: "720P",
    size: "16:9",
    duration: 5,
  };

  const headers = {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  };

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload),
  })
    .then((response) => response.json())
    .then((data) => console.log(data))
    .catch((error) => console.error("Error:", error));
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )

  func main() {
      url := "https://api.apimart.ai/v1/videos/generations"

      payload := map[string]interface{}{
          "model":      "wan3.0-video",
          "prompt":     "子猫が月明かりの屋根を駆け抜ける",
          "resolution": "720P",
          "size":       "16:9",
          "duration":   5,
      }

      jsonData, _ := json.Marshal(payload)
      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, _ := ioutil.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```
</RequestExample>

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

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "リクエストパラメータが無効です",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "認証に失敗しました。APIキーを確認してください",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "残高が不足しています。チャージしてから再試行してください",
      "type": "payment_required"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "リクエストが多すぎます。しばらくしてからお試しください",
      "type": "rate_limit_error"
    }
  }
  ```
</ResponseExample>

## 認証

<ParamField header="Authorization" type="string" required>
  すべてのエンドポイントで Bearer Token 認証が必要です

  [API キー管理ページ](https://apimart.ai/keys) から API キーを取得してください：

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

## 生成モード

モデル名は **`wan3.0-video`** で固定。リクエストフィールドによってモードが決まります：

| モード          | 典型的な入力                                                                       |
| ------------ | ---------------------------------------------------------------------------- |
| テキストから動画     | `prompt` のみ                                                                  |
| 先頭フレームから動画   | `image_urls` に 1 枚（フレーム族）                                                    |
| 先頭・最終フレーム    | `image_urls` に 2 枚、または `image_with_roles` で `first_frame` / `last_frame` を指定 |
| 参照から動画       | 参照画像 / 動画 / 音声；プロンプトで「图1 / 视频1 / 音频1」形式のラベルを使用可                              |
| ファイル / ページ参照 | `file_url` または `link_url`（`prompt` は任意）                                      |

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

### 基本

<ParamField body="model" type="string" required>
  固定値：`wan3.0-video`
</ParamField>

<ParamField body="prompt" type="string">
  テキスト説明。メディアフィールドと**少なくともどちらか一方が必須**。

  * 最大 **20,000** 文字。超過分はエラーなく自動切り捨て
  * 参照モードでは「图N / 视频N / 音频N」で素材を指定。番号は**各メディア種別内の順序**に従う
</ParamField>

<ParamField body="resolution" type="string" default="1080P">
  出力解像度（大文字小文字を区別しない）

  * `480P`
  * `720P`
  * `1080P`（**デフォルト**、最上位価格）

  <Warning>
    `resolution` を省略すると **1080P** で課金されます。コストを抑えたい場合は `480P` または `720P` を明示してください。
  </Warning>
</ParamField>

<ParamField body="size" type="string" default="adaptive">
  アスペクト比。`aspect_ratio` も受け付けます。

  * `adaptive`（デフォルト）
  * `16:9` / `4:3` / `1:1` / `3:4` / `9:16`
</ParamField>

<ParamField body="duration" type="integer" default="5">
  生成尺（秒）：

  * `2`–`30`：出力尺を指定（デフォルト `5`）
  * `-1`：尺は**モデルが決定**

  <Note>
    参照動画入力がある場合、入力動画の合計尺 + 出力尺は 30 秒以下である必要があります。`duration: -1` の場合もモデルが選ぶ尺がこの制約を満たす必要があります。
  </Note>
</ParamField>

<ParamField body="audio" type="boolean" default="true">
  出力に音声トラックを含めるか。デフォルト `true`。**音声の有無で価格は変わりません。**
</ParamField>

<ParamField body="seed" type="integer">
  乱数シード、範囲 `[0, 2147483647]`
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  透かしを付けるか。デフォルト `false`
</ParamField>

<ParamField body="generation_type" type="string">
  素の `image_urls` の帰属先：

  * `frame` — 先頭・最終フレーム族
  * `reference` — 参照族

  省略時は自動判定（相互排他ルールを参照）。
</ParamField>

### メディア入力

<ParamField body="image_urls" type="string[]">
  画像 URL 配列。ロール割当は相互排他ルールに従います。

  公開 URL または Base64（`data:image/png;base64,...`）。
</ParamField>

<ParamField body="image_with_roles" type="object[]">
  ロール付き画像配列。各項目：

  * `url`：画像アドレス
  * `role`：`first_frame` / `last_frame` / `reference_image`（一般的な別名も可）
</ParamField>

<ParamField body="video_urls" type="string[]">
  参照動画、最大 **5** 本。各 1–15 秒、**合計 ≤ 15 秒**
</ParamField>

<ParamField body="audio_urls" type="string[]">
  参照音声、最大 **5** 本。各 1–15 秒、**合計 ≤ 15 秒**
</ParamField>

<ParamField body="audio_url" type="string">
  単一の参照音声（`audio_urls` の単値形式）
</ParamField>

<ParamField body="file_url" type="string">
  参照ドキュメント URL、最大 **1** 個。**`link_url` と同時指定不可。**

  対応形式：docx / doc / xlsx / xls / pptx / ppt / pdf / txt / key / pages / numbers / md など、≤100MB、≤50 ページ。
</ParamField>

<ParamField body="link_url" type="string">
  公開 Web ページ URL、最大 **1** 個。ログイン不要のページのみ。**`file_url` と同時指定不可。**
</ParamField>

## メディア族の相互排他

メディアは 2 族のいずれかで、**混在不可**（送信前に検証 → 400、タスク未作成・課金なし）：

| 族         | メンバー                                                                | 意味                |
| --------- | ------------------------------------------------------------------- | ----------------- |
| **フレーム族** | `first_frame`、`last_frame`                                          | 動画の厳密な先頭 / 最終フレーム |
| **参照族**   | `reference_image`、`reference_video`、`reference_audio`、`file`、`link` | モデルが内容を自由に解釈      |

### 素の `image_urls` の割当

1. `generation_type` が指定されている → それに従う（`frame` / `reference`）
2. 未指定だが、リクエストに参照族入力がある（`video_urls` / `audio_urls` / `audio_url` / `file_url` / `link_url`）→ `reference_image` として扱う
3. どちらでもない → フレーム族：1 枚目 `first_frame`、2 枚目 `last_frame`（`wan2.7` と同じ）

精密に制御する場合は `image_with_roles` を使用してください。

### メディア上限と形式

| 種別          | 制限                                                            |
| ----------- | ------------------------------------------------------------- |
| 先頭 / 最終フレーム | 各 ≤ 1 枚                                                       |
| 参照画像        | ≤ 10 枚                                                        |
| 参照動画        | ≤ 5 本、各 1–15s、合計 ≤15s；mp4/mov；辺 240–4096 px、アスペクト ≤8:1、≤100MB |
| 参照音声        | ≤ 5 本、各 1–15s、合計 ≤15s；wav/mp3；≤15MB                           |
| 画像          | JPEG/JPG/PNG（透過なし）/ BMP / WEBP；辺 240–8000 px、アスペクト ≤8:1、≤20MB |
| ドキュメント      | ≤100MB、≤50 ページ                                                |
| Web ページ     | 公開・ログイン不要 URL                                                 |

## リクエスト例

### テキストから動画

```json theme={null}
{
  "model": "wan3.0-video",
  "prompt": "子猫が月明かりの屋根を駆け抜け、遠くで街のネオンが瞬く。映画級の画質、滑らかなカメラワーク。",
  "resolution": "720P",
  "size": "16:9",
  "duration": 5
}
```

### 先頭フレームから動画

```json theme={null}
{
  "model": "wan3.0-video",
  "prompt": "画面の人物がラップを始め、カメラがゆっくり寄っていく",
  "image_urls": ["https://example.com/first.png"],
  "resolution": "720P",
  "duration": 5
}
```

### 先頭・最終フレーム

```json theme={null}
{
  "model": "wan3.0-video",
  "prompt": "微笑みから笑い声へ、背景の光が寒色から暖色へ",
  "image_urls": [
    "https://example.com/first.png",
    "https://example.com/last.jpg"
  ],
  "duration": 5
}
```

または `image_with_roles` を使用：

```json theme={null}
{
  "model": "wan3.0-video",
  "prompt": "微笑みから笑い声へ",
  "image_with_roles": [
    {"url": "https://example.com/first.png", "role": "first_frame"},
    {"url": "https://example.com/last.jpg", "role": "last_frame"}
  ],
  "duration": 5
}
```

### マルチモーダル参照

```json theme={null}
{
  "model": "wan3.0-video",
  "prompt": "视频1抱着图1，在图3的椅子上弹奏一支舒缓的乡村民谣，并说道：\"今天的阳光真好。\"",
  "generation_type": "reference",
  "image_urls": [
    "https://example.com/object1.jpg",
    "https://example.com/object2.png",
    "https://example.com/chair.png"
  ],
  "video_urls": ["https://example.com/role.mp4"],
  "resolution": "480P",
  "duration": 5
}
```

> `video_urls` がある場合、素の `image_urls` は参照画像に自動分類されます。`generation_type: "reference"` を明示するとより明確です。

### ファイル参照から動画

`prompt` は省略可。ドキュメント内容で生成が駆動されます：

```json theme={null}
{
  "model": "wan3.0-video",
  "file_url": "https://example.com/glass.pptx",
  "resolution": "480P",
  "duration": 10
}
```

### Web ページ参照から動画

```json theme={null}
{
  "model": "wan3.0-video",
  "prompt": "この記事を教育向けの短い動画にして",
  "link_url": "https://example.com/article/123",
  "duration": 15
}
```

## 課金

**秒数 × 解像度**（公式リスト価格に準拠）。音声のオン/オフは価格に影響しません：

| 解像度   | 単価            | 5 秒   | 30 秒   |
| ----- | ------------- | ----- | ------ |
| 480P  | **¥0.30** / 秒 | ¥1.50 | ¥9.00  |
| 720P  | **¥0.60** / 秒 | ¥3.00 | ¥18.00 |
| 1080P | **¥1.20** / 秒 | ¥6.00 | ¥36.00 |

* デフォルトは **1080P**（最上位価格）。コスト重視なら `480P` / `720P` を指定
* 課金秒数：`2`–`30` のときはリクエストの `duration`；`-1` のときはモデルの**実出力**秒数
* `audio: true/false` は**価格に影響しません**

## 制限と注意

| 項目        | 説明                             |
| --------- | ------------------------------ |
| 尺         | 整数 `2`–`30`、または `-1`（モデルが尺を決定） |
| 動画入力ありの場合 | 入力動画合計尺 + 出力尺 ≤ 30 秒           |
| 生成時間      | 通常 1–5 分。長いクリップはさらに時間を要する      |
| 結果 URL    | 成功後にプラットフォーム CDN へミラー。長期利用可能   |
| プロンプト     | ≤20,000 文字。超過は切り捨て             |

## よくあるエラー

いずれも**同期 400**（タスク未作成・課金なし）：

| ケース                           | 対応                                                  |
| ----------------------------- | --------------------------------------------------- |
| フレーム族と参照族の混在                  | `generation_type` で一方を選ぶか、`image_with_roles` でロール指定 |
| `file_url` と `link_url` の同時指定 | どちらか一方を選択                                           |
| 不正な `duration`                | `2`–`30` または `-1` のみ                                |
| 非対応解像度（例：4K）                  | `480P` / `720P` / `1080P` のみ                        |
| 参照画像が 10 枚超                   | ≤10 枚に削減                                            |
| `prompt` とメディアが両方空            | 少なくとも一方を指定                                          |

## Response

<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>

<Note>
  **結果の照会**

  動画生成は非同期です。[タスク状態の取得](/ja/api-reference/tasks/status) または `GET /v1/videos/generations/{task_id}` でポーリングしてください。

  推奨間隔は 5–10 秒。生成には通常 1–5 分かかります。成功後は `result.videos` 内の URL を使用します。
</Note>
