> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-chore-sync-comfy-api-v2-spec.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router で Wan 2.6 I2V を使う

> Comfy Router を通じて HTTP 経由で wan/wan2.6-i2v を呼び出すための Python、TypeScript、cURL スニペット、およびリクエストフィールドと結果の形状

Wan 2.6 I2V の API リファレンスです。Wan 2.6 の画像から動画へは、静止した最初のフレームをアニメーション化します。720P または 1080P、最大 15 秒に対応しています。

## クイックスタート

[Comfy ワークスペース](https://platform.comfy.org/profile/api-keys)でキーを作成し、`COMFY_API_KEY` としてエクスポートします。Python と TypeScript のスニペットは Comfy SDK を使用します（`pip install comfy-sdk`、`npm install @comfyorg/sdk`）。cURL のスニペットは同じ呼び出しを raw HTTP で実行するものです。

**Model ID:** `wan/wan2.6-i2v`

**エンドポイント:** `POST https://api.comfy.org/v2/models/wan/wan2.6-i2v`

<Tabs>
  <Tab title="Wait for the result">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # Reads COMFY_API_KEY from the environment.
      # The SDK automatically creates an idempotency key and reuses it for automatic retries.
      with Comfy() as client:
          result = client.models.run(
              "wan/wan2.6-i2v",
              {
                  "input": {
                      "prompt": "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady",
                      "img_url": "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png",
                  },
                  "parameters": {
                      "resolution": "720P",
                      "duration": 5,
                  },
              },
          )

      print("video:", result["output"]["video_url"])
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // Reads COMFY_API_KEY from the environment.
      // The SDK automatically creates an idempotency key and reuses it for automatic retries.
      type Result = { output: { video_url: string } };
      const { data } = await comfy.models.run<Result>("wan/wan2.6-i2v", {
        input: {
          prompt: "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady",
          img_url: "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png",
        },
        parameters: {
          resolution: "720P",
          duration: 5,
        },
      });

      console.log("video:", data.output.video_url);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/wan/wan2.6-i2v \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"prompt\":\"the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady\",\"img_url\":\"https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png\"}, \"parameters\": {\"resolution\":\"720P\",\"duration\":5}}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # Reads COMFY_API_KEY from the environment.
      # Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
      with Comfy() as client:
          handle = client.models.submit(
              "wan/wan2.6-i2v",
              {
                  "input": {
                      "prompt": "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady",
                      "img_url": "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png",
                  },
                  "parameters": {
                      "resolution": "720P",
                      "duration": 5,
                  },
              },
          )
          print("request_id:", handle.request_id)  # with the model ID, all another process needs

          # Poll until the request completes, waiting the Retry-After the server names.
          for update in handle.iter_events():
              print(update.status, update.queue_position)

          # The provider's own payload, the same value models.run() returns.
          # A request that failed or was cancelled raises the typed Router error here.
          result = handle.get()

      print("video:", result["output"]["video_url"])
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // Reads COMFY_API_KEY from the environment.
      // Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
      type Result = { output: { video_url: string } };
      const handle = await comfy.models.submit<Result>("wan/wan2.6-i2v", {
        input: {
          prompt: "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady",
          img_url: "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png",
        },
        parameters: {
          resolution: "720P",
          duration: 5,
        },
      });
      console.log("requestId:", handle.requestId); // with the model ID, all another process needs

      // Poll until the request completes, waiting the Retry-After the server names.
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      // The same result models.run() returns. A request that failed or was cancelled rejects here.
      const result = await handle.get();
      if (result.kind !== "json") throw new Error("expected a JSON result");

      console.log("video:", result.data.output.video_url);
      ```

      ```bash cURL theme={null}
      # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
      curl https://api.comfy.org/v2/models/wan/wan2.6-i2v/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"prompt\":\"the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady\",\"img_url\":\"https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png\"}, \"parameters\": {\"resolution\":\"720P\",\"duration\":5}}"

      # 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.
      REQUEST_ID="<request_id from the 201 body>"
      curl -i https://api.comfy.org/v2/models/wan/wan2.6-i2v/requests/$REQUEST_ID/status \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.
      curl https://api.comfy.org/v2/models/wan/wan2.6-i2v/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="input" type="object" required>
  プロンプトなどの基本情報を入力します。
</ParamField>

<ParamField body="input.audio_url" type="string">
  オーディオファイルのダウンロードURL。対応形式: mp3、wav。reference\_video\_urls と併用できません。
</ParamField>

<ParamField body="input.img_url" type="string">
  先頭フレームの画像URLまたはBase64エンコードデータ。I2V モデルでは必須です。画像形式: JPEG、JPG、PNG、BMP、WEBP。解像度: 360～2000ピクセル。ファイルサイズ: 最大10MB。
</ParamField>

<ParamField body="input.media" type="object[]">
  wan2.7 および wan3.0 モデル用のメディアアセットリスト。ビデオ生成用の参照素材（画像、オーディオ、ビデオ）を指定します。各要素は type フィールドと url フィールドを含みます。
  サポートされる type の値はモデルによって異なります:

  * wan2.7-i2v: first\_frame、last\_frame、driving\_audio、first\_clip
  * wan2.7-r2v: reference\_image、reference\_video
  * wan2.7-videoedit: video、reference\_image
  * wan3.0-video: first\_frame（最大1）、last\_frame（最大1）、reference\_image（最大10）、
    reference\_video（最大5クリップ、合計再生時間 \<= 15s）、reference\_audio（最大5クリップ、
    合計再生時間 \<= 15s）、file（最大1、link と併用不可）、link（最大1、file と
    併用不可）。reference\_\*/file/link タイプと first\_frame/last\_frame タイプは
    同一リクエスト内で同時に使用できません。配列の順序が、プロンプト内でのアセットの
    参照順序（Image 1、Video 1、Audio 1、...）を定義します。
</ParamField>

<ParamField body="input.media[].type" type="string" required>
  メディアアセットのタイプ

  指定可能な値: `first_frame`, `last_frame`, `driving_audio`, `first_clip`, `reference_image`, `reference_video`, `reference_audio`, `video`, `file`, `link`
</ParamField>

<ParamField body="input.media[].url" type="string" required>
  メディアファイルのURL（公開 HTTP/HTTPS URL または OSS 一時 URL）
</ParamField>

<ParamField body="input.negative_prompt" type="string">
  ネガティブプロンプト。動画の画面に表示したくない内容を記述するために使用します
</ParamField>

<ParamField body="input.prompt" type="string">
  テキストプロンプト。中国語と英語に対応しており、長さは800文字以内です
  （wan3.0-video では最大20,000文字。制限を超えたコンテンツは切り捨てられます）。
  複数の参照ビデオを使用する wan2.6-r2v では、'character1'、'character2' などを使用して、
  参照ビデオの順序で被写体を参照します。例: 「Character1 sings on the roadside, Character2 dances beside it」
  wan3.0-video の参照モードでは、'Image 1'、'Video 1'、'Audio 1' などを使用して、media 配列内の
  対応する順序でメディアアセットを参照します。
</ParamField>

<ParamField body="input.reference_video_urls" type="string[]">
  wan2.6-r2v モデル専用の参照ビデオURL。1～3個のビデオURLの配列。
  入力制限:

  * 形式: mp4、mov
  * 数量: 1～3本のビデオ
  * 単一ビデオの長さ: 2～30秒
  * 単一ファイルサイズ: 最大30MB
  * audio\_url と併用できません
    参照再生時間: 単一ビデオは最大5秒、2本のビデオは各最大2.5秒、3本のビデオは比例して短くなります。
    課金: 実際に使用した参照再生時間に基づきます。
</ParamField>

<ParamField body="input.template" type="string">
  ビデオエフェクトテンプレート名。任意。現在サポートされているのは squish、flying、carousel です。使用すると prompt パラメータは無視されます。
</ParamField>

<ParamField body="model" type="string">
  呼び出すモデルの ID。このコンポーネントでは制約されません: Comfy Router は `POST /v2/models/wan/{model}` の `{model}` パスセグメントからこれを設定するため、Router の呼び出し元は省略します。`POST /proxy/wan/api/v1/services/aigc/video-generation/video-synthesis` への直接の v1 呼び出しでは必ず指定する必要があり、受け付けられる綴りの enum はそのオペレーション自身のコンポーネント `WanVideoGenerationRequest` にあります。
</ParamField>

<ParamField body="parameters" type="object">
  ビデオ処理パラメータ
</ParamField>

<ParamField body="parameters.audio" type="boolean" default="true">
  ビデオにオーディオを追加するかどうか
</ParamField>

<ParamField body="parameters.audio_setting" type="string" default="&#x22;auto&#x22;">
  wan2.7-videoedit モデル用のビデオオーディオ設定。

  * auto（デフォルト）: モデルがプロンプトの内容に基づいてインテリジェントに判断します
  * origin: 入力ビデオのオリジナルオーディオを強制的に保持します

    指定可能な値: `auto`, `origin`
</ParamField>

<ParamField body="parameters.duration" type="integer" default="5">
  生成されるビデオの長さ（秒）:

  * wan2.5 モデル: 5秒または10秒
  * wan2.6-t2v、wan2.6-i2v: 5、10、または15秒
  * wan2.6-r2v: 5秒または10秒のみ（15秒は非対応）
  * wan2.7-i2v、wan2.7-t2v: \[2, 15] の整数
  * wan2.7-r2v、wan2.7-videoedit: \[2, 10] の整数
  * wan3.0-video: ビデオ入力なしの場合は \[2, 30] の整数。ビデオ入力ありの場合は、
    入力ビデオの合計再生時間 + 出力ビデオの再生時間が30秒を超えてはなりません。なお、
    -1 を指定するとスマート再生時間モードが有効になり、モデルが適切な長さを選択します

    範囲: `-1` ～ `30`
</ParamField>

<ParamField body="parameters.prompt_extend" type="boolean" default="true">
  プロンプトのインテリジェントな書き換えを有効にするかどうか。デフォルトは true です
</ParamField>

<ParamField body="parameters.ratio" type="string">
  生成されるビデオの比率。wan2.7 および wan3.0 モデル専用です。
  wan2.7 モデルでは、指定しない場合は解像度ティアに基づいてデフォルトが決まります。
  wan3.0-video では、adaptive（デフォルト）が入力メディアの比率と意図に基づいて
  適切な比率を自動的に推奨します。

  指定可能な値: `adaptive`, `16:9`, `9:16`, `1:1`, `4:3`, `3:4`
</ParamField>

<ParamField body="parameters.resolution" type="string">
  解像度レベル。サポートされる値はモデルによって異なります:

  * wan2.5-i2v-preview: 480P、720P、1080P
  * wan2.6-i2v: 720P、1080P のみ（480P 非対応）
  * wan2.7 モデル（i2v、t2v、r2v、videoedit）: 720P、1080P（デフォルト 1080P）
  * wan3.0-video、wan3.0-video-prime: 480P、720P、1080P（上流のデフォルトは 1080P）
    このプロキシは、resolution と size のどちらも指定されていないビデオ生成リクエストを
    拒否します。解像度ティアが課金レートを決定するためです。

    指定可能な値: `480P`, `720P`, `1080P`
</ParamField>

<ParamField body="parameters.seed" type="integer">
  乱数シード。モデルが生成するコンテンツのランダム性を制御するために使用します。

  範囲: `0` から `2147483647`
</ParamField>

<ParamField body="parameters.shot_type" type="string" default="&#x22;single&#x22;">
  インテリジェントなマルチレンズ制御。prompt\_extend が有効な場合にのみ動作します。
  wan2.6 および wan2.7-r2v モデル用。

  * single: シングルショットビデオ（デフォルト）
  * multi: マルチショットビデオ

    指定可能な値: `multi`、`single`
</ParamField>

<ParamField body="parameters.size" type="string">
  幅*高さ形式のビデオ解像度。対応する解像度はモデルによって異なります:
  wan2.5 T2V の場合: 480P（480*832、832*480、624*624）、720P、1080P サイズ
  wan2.6 T2V/R2V の場合（480P なし）:
  720P: 1280*720、720*1280、960*960、1088*832、832*1088
  1080P: 1920*1080、1080*1920、1440*1440、1632*1248、1248*1632
</ParamField>

<ParamField body="parameters.watermark" type="boolean" default="false">
  ウォーターマークロゴを追加するかどうか。ウォーターマークは右下隅に配置されます。
</ParamField>

スキーマから生成されています。Router は `GET /v2/models/wan/wan2.6-i2v/openapi.json` でこのスキーマを提供しており、リクエストがプロバイダーに到達する前に、呼び出しを検証する際に使用するドキュメントと同じものです。

### 出力

<ResponseField name="output" type="object" required />

<ResponseField name="output.actual_prompt" type="string">
  インテリジェントな書き換え後の実際のプロンプト（ビデオタスク用）
</ResponseField>

<ResponseField name="output.check_audio" type="string">
  オーディオ生成を伴うI2Vタスク用のオーディオURL
</ResponseField>

<ResponseField name="output.code" type="string">
  失敗したリクエストのエラーコード（リクエストが成功した場合は返されません）
</ResponseField>

<ResponseField name="output.end_time" type="string">
  タスク完了時間
</ResponseField>

<ResponseField name="output.message" type="string">
  失敗したリクエストの詳細情報（リクエストが成功した場合は返されません）
</ResponseField>

<ResponseField name="output.orig_prompt" type="string">
  オリジナルの入力プロンプト（ビデオタスク用）
</ResponseField>

<ResponseField name="output.results" type="object[]">
  画像生成タスクのタスク結果のリスト
</ResponseField>

<ResponseField name="output.results[].actual_prompt" type="string">
  インテリジェントな書き換え後の実際のプロンプト（有効な場合）
</ResponseField>

<ResponseField name="output.results[].code" type="string">
  画像のエラーコード（一部のタスクが失敗した場合に返されます）
</ResponseField>

<ResponseField name="output.results[].message" type="string">
  画像のエラー情報（一部のタスクが失敗した場合に返されます）
</ResponseField>

<ResponseField name="output.results[].orig_prompt" type="string">
  オリジナルの入力プロンプト
</ResponseField>

<ResponseField name="output.results[].url" type="string">
  生成された画像URLアドレス
</ResponseField>

<ResponseField name="output.scheduled_time" type="string">
  タスク実行時間
</ResponseField>

<ResponseField name="output.submit_time" type="string">
  タスク送信時間
</ResponseField>

<ResponseField name="output.task_id" type="string" required>
  タスクID
</ResponseField>

<ResponseField name="output.task_metrics" type="object">
  画像生成タスクのタスク結果統計
</ResponseField>

<ResponseField name="output.task_metrics.FAILED" type="integer">
  失敗したタスク数
</ResponseField>

<ResponseField name="output.task_metrics.SUCCEEDED" type="integer">
  成功したタスク数
</ResponseField>

<ResponseField name="output.task_metrics.TOTAL" type="integer">
  タスクの合計数
</ResponseField>

<ResponseField name="output.task_status" type="string" required>
  タスクステータス

  取りうる値: `PENDING`、`RUNNING`、`SUCCEEDED`、`FAILED`、`CANCELED`、`UNKNOWN`
</ResponseField>

<ResponseField name="output.video_url" type="string">
  完了したビデオ生成タスクのビデオURL。リンクの有効期間は24時間
</ResponseField>

<ResponseField name="request_id" type="string" required>
  一意のリクエスト識別子
</ResponseField>

<ResponseField name="usage" type="object">
  出力情報の統計。成功した結果のみがカウントされます
</ResponseField>

<ResponseField name="usage.SR" type="integer">
  ビデオ解像度レベル（I2Vおよびwan3.0-videoタスク）
</ResponseField>

<ResponseField name="usage.duration" type="number">
  生成されたビデオの再生時間（秒）（I2Vおよびwan3.0-videoタスク）
</ResponseField>

<ResponseField name="usage.fps" type="integer">
  生成されたビデオのフレームレート（wan3.0-videoタスク）
</ResponseField>

<ResponseField name="usage.image_count" type="integer">
  生成された画像数（T2IおよびI2Iタスク）
</ResponseField>

<ResponseField name="usage.input_video_duration" type="number">
  入力ビデオの再生時間（秒）。ビデオ入力がない場合は0.0（wan3.0-videoタスク）
</ResponseField>

<ResponseField name="usage.output_video_duration" type="number">
  出力ビデオの再生時間（秒）（wan3.0-videoタスク）
</ResponseField>

<ResponseField name="usage.ratio" type="string">
  生成されたビデオのアスペクト比。例: 16:9（wan3.0-videoタスク）
</ResponseField>

<ResponseField name="usage.size" type="string">
  画像の解像度（T2IおよびI2Iタスク）
</ResponseField>

<ResponseField name="usage.video_count" type="integer">
  生成されたビデオ数（T2Vタスク）
</ResponseField>

<ResponseField name="usage.video_duration" type="number">
  生成されたビデオの再生時間（秒）（T2Vタスク）
</ResponseField>

<ResponseField name="usage.video_ratio" type="string">
  ビデオ解像度の比率（T2Vタスク）
</ResponseField>

<ResponseField name="code" type="string">
  失敗したリクエストのエラーコード。`output` の下ではなく、エンベロープのルートで報告されます（リクエストが成功した場合は返されません）。
</ResponseField>

<ResponseField name="message" type="string">
  失敗したリクエストの詳細情報。`output` の下ではなく、エンベロープのルートで報告されます（リクエストが成功した場合は返されません）。`output.message` にフォールバックする前にこちらを確認してください。
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "input": {
    "prompt": "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady",
    "img_url": "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/pink_robot_front.png"
  },
  "parameters": {
    "resolution": "720P",
    "duration": 5
  }
}
```

### 出力

```json theme={null}
{
  "output": {
    "task_id": "0385dc79-5ff8-4d82-bcb6-7c1a9f2e4d60",
    "task_status": "SUCCEEDED",
    "submit_time": "2027-01-01T00:00:00.000Z",
    "scheduled_time": "2027-01-01T00:00:01.000Z",
    "end_time": "2027-01-01T00:01:04.000Z",
    "orig_prompt": "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady",
    "actual_prompt": "the robot lowers its raised arm and steps toward the camera, the flat orange backdrop holds steady, smooth studio lighting, subtle camera push in",
    "video_url": "https://.../generated.mp4"
  },
  "request_id": "7574ee8f-38a3-4b1e-9280-11c33ab46e51",
  "usage": {
    "SR": 720,
    "duration": 5
  }
}
```

ビデオのURLは24時間有効です。保存が必要な場合は、速やかにビデオをダウンロードしてください。

## 出荷前の確認

SDK は `Idempotency-Key` を生成し、自動リトライで再利用します。手動リトライでは元のキーを再利用してください。Router は最大 10 分間接続を保持できます。

リクエストが失敗すると、Router は理由を示す `X-Comfy-Error-Type` レスポンスヘッダーを送信します。`422` は、プロバイダーを呼び出す前に Router が入力を拒否したことを意味します。生成されたアセットは [結果 URL の有効期限](/ja/development/comfy-router/reference#結果アセット) があるため、早めにダウンロードしてください。

<CardGroup cols={3}>
  <Card title="ヘッダー" icon="list" href="/ja/development/comfy-router/quickstart">
    認証、冪等性、リクエスト ID、エラー分類、リトライ間隔、支出上限。
  </Card>

  <Card title="Router API の利用" icon="code" href="/ja/development/comfy-router/quickstart">
    モデルの検出、バリデーションエラー、リトライ、課金。
  </Card>

  <Card title="制限事項" icon="triangle-exclamation" href="/ja/development/comfy-router/limitations">
    Router が現在対応していないことと、代替手段。
  </Card>
</CardGroup>
