> ## 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 T2I Preview を使用する

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

`wan/wan2.5-t2i-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-t2i-preview`

**エンドポイント:** `POST https://api.comfy.org/v2/models/wan/wan2.5-t2i-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-t2i-preview",
              {
                  "input": {
                      "prompt": "A single red maple leaf on a plain white background.",
                  },
                  "parameters": {
                      "n": 1,
                      "size": "1280*1280",
                  },
              },
          )

      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-t2i-preview", {
        input: {
          prompt: "A single red maple leaf on a plain white background.",
        },
        parameters: {
          n: 1,
          size: "1280*1280",
        },
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/wan/wan2.5-t2i-preview \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"prompt\":\"A single red maple leaf on a plain white background.\"}, \"parameters\": {\"n\":1,\"size\":\"1280*1280\"}}"
      ```
    </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-t2i-preview",
              {
                  "input": {
                      "prompt": "A single red maple leaf on a plain white background.",
                  },
                  "parameters": {
                      "n": 1,
                      "size": "1280*1280",
                  },
              },
          )
          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-t2i-preview", {
        input: {
          prompt: "A single red maple leaf on a plain white background.",
        },
        parameters: {
          n: 1,
          size: "1280*1280",
        },
      });
      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-t2i-preview/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"prompt\":\"A single red maple leaf on a plain white background.\"}, \"parameters\": {\"n\":1,\"size\":\"1280*1280\"}}"

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

## スキーマ

### 入力

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

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

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

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

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

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

  範囲: `1` から `4`
</ParamField>

<ParamField body="parameters.prompt_extend" type="boolean" default="true">
  プロンプトのインテリジェント書き換えを有効にします。デフォルトは true
</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 は 1638400 (1280*1280) から 2073600 (1440*1440) までのピクセル面積を、1:4 から 4:1 の間のアスペクト比で受け入れます。そのため 768\*2700 も有効です。
</ParamField>

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

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

### 出力

<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": "A single red maple leaf on a plain white background."
  },
  "parameters": {
    "n": 1,
    "size": "1280*1280"
  }
}
```

### 出力

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