> ## 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.7 Video Edit を使用する

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

Wan 2.7 Video Edit の API リファレンス。Wan 2.7 video edit は、テキスト指示に基づいて既存のクリップを書き換え、必要に応じて参照画像でガイドします。

## クイックスタート

[あなたの 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.7-videoedit`

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

<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.7-videoedit",
              {
                  "input": {
                      "prompt": "restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged",
                      "media": [
                          {
                              "type": "video",
                              "url": "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/street_dancer.mp4",
                          },
                      ],
                  },
                  "parameters": {
                      "resolution": "720P",
                      "audio_setting": "origin",
                  },
              },
          )

      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.7-videoedit", {
        input: {
          prompt: "restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged",
          media: [
            {
              type: "video",
              url: "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/street_dancer.mp4",
            },
          ],
        },
        parameters: {
          resolution: "720P",
          audio_setting: "origin",
        },
      });

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

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/wan/wan2.7-videoedit \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"prompt\":\"restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged\",\"media\":[{\"type\":\"video\",\"url\":\"https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/street_dancer.mp4\"}]}, \"parameters\": {\"resolution\":\"720P\",\"audio_setting\":\"origin\"}}"
      ```
    </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.7-videoedit",
              {
                  "input": {
                      "prompt": "restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged",
                      "media": [
                          {
                              "type": "video",
                              "url": "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/street_dancer.mp4",
                          },
                      ],
                  },
                  "parameters": {
                      "resolution": "720P",
                      "audio_setting": "origin",
                  },
              },
          )
          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.7-videoedit", {
        input: {
          prompt: "restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged",
          media: [
            {
              type: "video",
              url: "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/street_dancer.mp4",
            },
          ],
        },
        parameters: {
          resolution: "720P",
          audio_setting: "origin",
        },
      });
      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.7-videoedit/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"prompt\":\"restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged\",\"media\":[{\"type\":\"video\",\"url\":\"https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/street_dancer.mp4\"}]}, \"parameters\": {\"resolution\":\"720P\",\"audio_setting\":\"origin\"}}"

      # 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.7-videoedit/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.7-videoedit/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クリップ、合計再生時間 \<= 15秒）、reference\_audio（最大5クリップ、
    合計再生時間 \<= 15秒）、file（最大1、linkとは併用不可）、link（最大1、fileとは
    併用不可）。reference\_\*/file/link タイプと first\_frame/last\_frame タイプは
    同一リクエスト内で相互排他的です。配列の順序が、プロンプト内のアセットの参照順序
    （画像1、ビデオ1、オーディオ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）
    このプロキシは、解像度もサイズも指定されていないビデオ生成リクエストを拒否します。
    これは、解像度ティアが課金レートを決定するためです。

    指定可能な値: `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">
  width*height 形式のビデオ解像度。サポートされる解像度はモデルによって異なります:
  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>

`GET /v2/models/wan/wan2.7-videoedit/openapi.json` で Router が提供するスキーマから生成されています。これは、リクエストがプロバイダーに到達する前に 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": "restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged",
    "media": [
      {
        "type": "video",
        "url": "https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/street_dancer.mp4"
      }
    ]
  },
  "parameters": {
    "resolution": "720P",
    "audio_setting": "origin"
  }
}
```

### 出力

```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": "restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged",
    "actual_prompt": "restyle the clip as a hand-drawn ink sketch, keep the dancer's movement unchanged, monochrome linework on paper texture",
    "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>
