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

# Comfy Router で Wan 2.5 I2I Preview を使用する

> Comfy Router 経由で wan/wan2.5-i2i-preview を呼び出します。エンドポイント、リクエスト形状、Router が返すレスポンスについて説明します。

`wan/wan2.5-i2i-preview` の API リファレンス。Wan の Comfy Router から提供されます。

## クイックスタート

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

**モデル ID:** `wan/wan2.5-i2i-preview`

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

<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.5-i2i-preview",
              {
                  "input": {
                      "images": ["https://example.invalid/red-maple-leaf.png"],
                      "prompt": "Make the leaf golden.",
                  },
                  "parameters": {
                      "n": 1,
                      "size": "768*768",
                  },
              },
          )

      print(result)
      ```

      ```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.
      const { data } = await comfy.models.run("wan/wan2.5-i2i-preview", {
        input: {
          images: ["https://example.invalid/red-maple-leaf.png"],
          prompt: "Make the leaf golden.",
        },
        parameters: {
          n: 1,
          size: "768*768",
        },
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/wan/wan2.5-i2i-preview \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"images\":[\"https://example.invalid/red-maple-leaf.png\"],\"prompt\":\"Make the leaf golden.\"}, \"parameters\": {\"n\":1,\"size\":\"768*768\"}}"
      ```
    </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.5-i2i-preview",
              {
                  "input": {
                      "images": ["https://example.invalid/red-maple-leaf.png"],
                      "prompt": "Make the leaf golden.",
                  },
                  "parameters": {
                      "n": 1,
                      "size": "768*768",
                  },
              },
          )
          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(result)
      ```

      ```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.
      const handle = await comfy.models.submit("wan/wan2.5-i2i-preview", {
        input: {
          images: ["https://example.invalid/red-maple-leaf.png"],
          prompt: "Make the leaf golden.",
        },
        parameters: {
          n: 1,
          size: "768*768",
        },
      });
      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();

      console.log(result.data);
      ```

      ```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.5-i2i-preview/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"images\":[\"https://example.invalid/red-maple-leaf.png\"],\"prompt\":\"Make the leaf golden.\"}, \"parameters\": {\"n\":1,\"size\":\"768*768\"}}"

      # 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.5-i2i-preview/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.5-i2i-preview/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### 入力

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

<ParamField body="input.images" type="string[]" required>
  画像から画像への生成に使用する画像 URL の配列
</ParamField>

<ParamField body="input.negative_prompt" type="string">
  画像に表示したくないコンテンツを記述するネガティブプロンプト
</ParamField>

<ParamField body="input.prompt" type="string" required>
  期待する画像の要素や視覚的特徴を記述するポジティブプロンプト。中国語と英語をサポートし、長さは 2000 文字以内です
</ParamField>

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

<ParamField body="parameters" type="object">
  画像処理パラメータ
</ParamField>

<ParamField body="parameters.n" type="integer" default="1">
  生成する画像の数。範囲は 1～4、デフォルトは 1

  範囲: `1` ～ `4`
</ParamField>

<ParamField body="parameters.seed" type="integer">
  ランダム性を制御する乱数シード。範囲 \[0, 2147483647]

  範囲: `0` ～ `2147483647`
</ParamField>

<ParamField body="parameters.size" type="string" default="&#x22;1280*1280&#x22;">
  幅*高さ形式の出力画像の解像度。デフォルトは 1280*1280 です。API は 589824 (768*768) から 1638400 (1280*1280) までのピクセル面積を、1:4 から 4:1 までのアスペクト比で受け付けます
</ParamField>

<ParamField body="parameters.watermark" type="boolean" default="false">
  右下隅に透かしロゴを追加するかどうか
</ParamField>

Router が `GET /v2/models/wan/wan2.5-i2i-preview/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` の下ではなく、エンベロープの ROOT で報告されます（リクエストが成功した場合は返されません）。
</ResponseField>

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

## 例

### 入力

```json theme={null}
{
  "input": {
    "images": [
      "https://example.invalid/red-maple-leaf.png"
    ],
    "prompt": "Make the leaf golden."
  },
  "parameters": {
    "n": 1,
    "size": "768*768"
  }
}
```

### 出力

```json theme={null}
{
  "output": {
    "end_time": "2027-01-01T00:00:12.000Z",
    "results": [
      {
        "actual_prompt": "a single red maple leaf resting on still water, shallow depth of field, soft morning light",
        "orig_prompt": "a single red maple leaf resting on still water",
        "url": "https://example.invalid/wan/generated-1.png"
      },
      {
        "code": "DataInspectionFailed",
        "message": "This candidate was rejected; the task as a whole succeeded.",
        "orig_prompt": "a single red maple leaf resting on still water"
      }
    ],
    "scheduled_time": "2027-01-01T00:00:01.000Z",
    "submit_time": "2027-01-01T00:00:00.000Z",
    "task_id": "0385dc79-5ff8-4d82-bcb6-7c1a9f2e4d60",
    "task_metrics": {
      "FAILED": 1,
      "SUCCEEDED": 1,
      "TOTAL": 2
    },
    "task_status": "SUCCEEDED"
  },
  "request_id": "7574ee8f-38a3-4b1e-9280-11c33ab46e51",
  "usage": {
    "image_count": 1,
    "size": "1280*1280"
  }
}
```

## 出荷前の確認

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>
