> ## 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 で Flashvsr を使用する

> Comfy Router 経由で wavespeed/flashvsr を呼び出します: エンドポイント、リクエストの形状、Router が返すレスポンスについて説明します。

`wavespeed/flashvsr` の API Reference。Comfy Router が WaveSpeed から提供します。

## クイックスタート

[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:** `wavespeed/flashvsr`

**エンドポイント:** `POST https://api.comfy.org/v2/models/wavespeed/flashvsr`

<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(
              "wavespeed/flashvsr",
              {
                  "duration": 4,
                  "target_resolution": "1080p",
                  "video": "https://samplelib.com/mp4/sample-30s.mp4",
              },
          )

      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("wavespeed/flashvsr", {
        duration: 4,
        target_resolution: "1080p",
        video: "https://samplelib.com/mp4/sample-30s.mp4",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/wavespeed/flashvsr \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"duration\": 4, \"target_resolution\": \"1080p\", \"video\": \"https://samplelib.com/mp4/sample-30s.mp4\"}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    同じボディを `POST https://api.comfy.org/v2/models/wavespeed/flashvsr/requests` に送信します。Router は実行が受け付けられ次第 `201` と `request_id` を返し、結果は準備が整った時点で、このプロセスからでも別のプロセスからでも取得できます。ステータス、キャンセル、結果の取得の詳細は [Queued delivery](/ja/development/comfy-router/queue) を参照してください。

    <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(
              "wavespeed/flashvsr",
              {
                  "duration": 4,
                  "target_resolution": "1080p",
                  "video": "https://samplelib.com/mp4/sample-30s.mp4",
              },
          )
          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("wavespeed/flashvsr", {
        duration: 4,
        target_resolution: "1080p",
        video: "https://samplelib.com/mp4/sample-30s.mp4",
      });
      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/wavespeed/flashvsr/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"duration\": 4, \"target_resolution\": \"1080p\", \"video\": \"https://samplelib.com/mp4/sample-30s.mp4\"}"

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

## スキーマ

### 入力

<ParamField body="duration" type="number" required>
  ビデオの再生時間（秒）
</ParamField>

<ParamField body="target_resolution" type="string" default="&#x22;1080p&#x22;">
  アップスケール先の解像度。

  指定可能な値: `720p`, `1080p`, `2k`, `4k`
</ParamField>

<ParamField body="video" type="string" required>
  アップスケールするビデオ。ビデオファイルへの URL、または base64 エンコードされたビデオを指定できます。
</ParamField>

これは Router が `GET /v2/models/wavespeed/flashvsr/openapi.json` で提供するスキーマから生成されたもので、リクエストがプロバイダーに到達する前に Router が呼び出しを検証する対象となるドキュメントと同じものです。

### 出力

<ResponseField name="code" type="integer">
  WavespeedAI 独自のエンベロープステータスコードで、HTTP ステータスを反映します（このスキーマが記述するドキュメントでは 200）。Wavespeed は一部の失敗をトランスポートステータスではなくここで報告します。
</ResponseField>

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

<ResponseField name="data.created_at" type="string">
  Wavespeed が予測を作成した時刻の ISO-8601 タイムスタンプ。
</ResponseField>

<ResponseField name="data.error" type="string">
  Wavespeed の自由記述形式の失敗理由。存在しない場合は空文字列。実際に失敗した予測は、このドキュメントではなく Comfy Router エラーとして Router の呼び出し元に届きます。
</ResponseField>

<ResponseField name="data.id" type="string">
  Router が送信してポーリングした予測に対する Wavespeed の識別子。
</ResponseField>

<ResponseField name="data.model" type="string">
  予測の実行に使用された Wavespeed モデル ID。
</ResponseField>

<ResponseField name="data.outputs" type="string[]" required>
  完了した生成物。Router が返すドキュメントでは存在し、空ではありません。このリストが結果そのものです。各要素は生成されたコンテンツへの URL（`wavespeed/flashvsr` では MP4、2 つのアップスケーラーでは画像）か、リクエストで `enable_base64_output` を設定した場合の 2 つの画像 ID については base64 エンコードされたバイト列そのものです。リンクは Wavespeed 独自のもので、有効期限があります。
</ResponseField>

<ResponseField name="data.status" type="string" required>
  Wavespeed が表記したとおりの予測のターミナル状態。ここでは enum に限定されていません。Router は値をそのまま転送し、ポーリングの分類器は比較前に小文字化するため、成功は `completed`、`succeeded`、`success`、`done` のいずれの形でも、大文字小文字を問わず正当に到着し得ます。
</ResponseField>

<ResponseField name="data.timings" type="object">
  Wavespeed 独自のタイミング測定値。
</ResponseField>

<ResponseField name="data.timings.inference" type="integer">
  推論時間（ミリ秒）。Wavespeed の数値であり、Comfy の課金時間ではありません。
</ResponseField>

<ResponseField name="data.urls" type="object">
  予測に対する Wavespeed 独自のリンク。
</ResponseField>

<ResponseField name="data.urls.get" type="string">
  Router がポーリングした予測結果の URL。
</ResponseField>

<ResponseField name="message" type="string">
  エンベロープのステータスメッセージ。例えば `success`。
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "duration": 4,
  "target_resolution": "1080p",
  "video": "https://samplelib.com/mp4/sample-30s.mp4"
}
```

### 出力

```json theme={null}
{
  "code": 200,
  "data": {
    "created_at": "2027-01-01T00:00:00Z",
    "error": "",
    "id": "3f6c1a90-2b47-4d18-9a55-7c0e8b21d4f3",
    "outputs": [
      "https://example.invalid/wavespeed/flashvsr/upscaled.mp4"
    ],
    "status": "completed",
    "timings": {
      "inference": 128000
    }
  },
  "message": "success"
}
```

## 出荷前の確認

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>
