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

# 将 Flashvsr 与 Comfy Router 配合使用

> 通过 Comfy Router 调用 wavespeed/flashvsr：端点、请求形状以及 Router 返回的响应。

`wavespeed/flashvsr` 的 API 参考，由 Comfy Router 从 WaveSpeed 提供。

## 快速开始

在[你的 Comfy 工作区](https://platform.comfy.org/profile/api-keys?onboarding=router)中创建一个密钥，并将其导出为 `COMFY_API_KEY`。Python、TypeScript 和 Swift 代码片段使用 Comfy SDK（`pip install comfy-sdk`、`npm install @comfyorg/sdk`，以及 [`ComfySwiftSDK`](https://github.com/Comfy-Org/comfy-swift-sdk) Swift 包）；cURL 代码片段是通过原始 HTTP 发起的同一调用。

**模型 ID：** `wavespeed/flashvsr`

**端点：** `POST https://api.comfy.org/v2/models/wavespeed/flashvsr`

<Tabs>
  <Tab title="等待结果">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # 从环境变量中读取 COMFY_API_KEY。
      # SDK 会自动创建幂等键，并在自动重试时复用它。
      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";

      // 从环境变量中读取 COMFY_API_KEY。
      // SDK 会自动创建幂等键，并在自动重试时复用它。
      const { data } = await comfy.models.run("wavespeed/flashvsr", {
        duration: 4,
        target_resolution: "1080p",
        video: "https://samplelib.com/mp4/sample-30s.mp4",
      });

      console.log(data);
      ```

      ```swift Swift theme={null}
      import Foundation
      import ComfySwiftSDK

      // 从环境变量中读取 COMFY_API_KEY。
      // SDK 会为每次调用生成一个幂等键，并在自动重试时复用它。
      let client = ComfyCloudClient(apiKey: ProcessInfo.processInfo.environment["COMFY_API_KEY"]!)
      let result = try await client.models.run(
          "wavespeed/flashvsr",
          input: [
              "duration": 4,
              "target_resolution": "1080p",
              "video": "https://samplelib.com/mp4/sample-30s.mp4",
          ]
      )

      print(result.output)
      ```

      ```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="入队并稍后收集">
    将相同的请求体发送到 `POST https://api.comfy.org/v2/models/wavespeed/flashvsr/requests`。运行被受理后，Router 会立即返回 `201` 和 `request_id`；结果就绪后，可以从本进程或其他进程收集。状态、取消与收集的细节见 [队列投递](/zh/development/comfy-router/queue)。

    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # 从环境变量读取 COMFY_API_KEY。
      # 每次 submit() 调用都会生成自己的 Idempotency-Key，并在自动重试时复用它。
      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)  # 配合模型 ID，就是另一个进程所需的全部信息

          # 轮询直到请求完成，按服务器给出的 Retry-After 等待。
          for update in handle.iter_events():
              print(update.status, update.queue_position)

          # 提供商自己的响应载荷，即 models.run() 返回的同一个值。
          # 失败或已取消的请求会在此处抛出带类型的 Router 错误。
          result = handle.get()

      print(result)
      ```

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

      // 从环境变量读取 COMFY_API_KEY。
      // 每次 submit() 调用都会生成自己的 Idempotency-Key，并在自动重试时复用它。
      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); // 配合模型 ID，就是另一个进程所需的全部信息

      // 轮询直到请求完成，按服务器给出的 Retry-After 等待。
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      // 与 models.run() 返回的结果相同。失败或已取消的请求会在此处被拒绝。
      const result = await handle.get();

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

      ```swift Swift theme={null}
      import Foundation
      import ComfySwiftSDK

      // 从环境变量读取 COMFY_API_KEY。
      // 每次 submit() 调用都会生成自己的 Idempotency-Key，并在自动重试时复用它。
      let client = ComfyCloudClient(apiKey: ProcessInfo.processInfo.environment["COMFY_API_KEY"]!)
      let handle = try await client.models.submit(
          "wavespeed/flashvsr",
          input: [
              "duration": 4,
              "target_resolution": "1080p",
              "video": "https://samplelib.com/mp4/sample-30s.mp4",
          ]
      )
      print("requestId:", handle.requestId)  // 配合模型 ID，就是另一个进程所需的全部信息

      // 轮询直到请求完成，按服务器给出的 Retry-After 等待。
      for try await update in handle.events() {
          print(update.state.rawValue, update.queuePosition.map(String.init) ?? "unknown")
      }

      // 提供商自己的响应载荷，即 models.run() 返回的同一个值。
      // 失败或已取消的请求会在此处抛出带类型的 Router 错误。
      let result = try await handle.result()

      print(result.output)
      ```

      ```bash cURL theme={null}
      # 1. 提交。Router 返回 201，并附带 request_id、status_url、response_url 和 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. 轮询直到状态为 COMPLETED，每次响应都按其给出的 Retry-After 秒数等待。
      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. 收集。返回 200 时携带模型的原生输出，仍在运行时返回 202 和状态响应体。
      curl https://api.comfy.org/v2/models/wavespeed/flashvsr/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### 输入

<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` 提供的 schema 生成，这也是请求到达提供商之前 Router 用于校验调用的同一份文档。

### 输出

<ResponseField name="code" type="integer">
  WavespeedAI 自身的信封状态码，与 HTTP 状态码对应（本 schema 所描述的文档中为 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">
  Wavespeed 为 Router 提交并轮询的该预测分配的标识符。
</ResponseField>

<ResponseField name="data.model" type="string">
  该预测运行所使用的 Wavespeed 模型 id。
</ResponseField>

<ResponseField name="data.outputs" type="string[]" required>
  已完成的生成结果。在 Router 返回的文档中一定存在且非空；该列表本身就是结果。每个元素都是指向已生成内容的 URL：对于 `wavespeed/flashvsr` 是 MP4，对于两个放大器是图像；或者当请求设置了 `enable_base64_output` 时，对于那两个图像 id，则为 base64 编码的字节本身。这些链接由 Wavespeed 提供，会过期。
</ResponseField>

<ResponseField name="data.status" type="string" required>
  该预测的终端状态，按 Wavespeed 的写法返回。此处不限定为枚举：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` 并在自动重试中复用它。手动重试时，请复用原始 key。Router 最长可保持连接 10 分钟。

请求失败时，Router 会发送 `X-Comfy-Error-Type` 响应头说明原因。`422` 表示 Router 在调用提供商之前就拒绝了输入，`413` 表示请求体超出了 Router 可接受的大小。已生成的资源请及时下载，因为[结果 URL 会过期](/zh/development/comfy-router/reference#结果资产)。

上文任何字段描述中提到的尺寸限制，都是提供商对该字段自身的限定，引自提供商的规范。Router 会对整个请求体另行设置上限，base64 编码的媒体内容也计入其中：参见[请求体大小](/zh/development/comfy-router/limitations)。

本页记录的是通过 Comfy Router 调用的某一个合作伙伴模型。同一个 `comfy-sdk` / `@comfyorg/sdk` 包还提供第二个客户端，用于在 Comfy Cloud 上运行完整的 ComfyUI 工作流图：`Comfy(api_key=...)` / `new Comfy({ apiKey })`，并带有 `client.workflows`、`client.assets` 和 `client.jobs`。请参阅 [Comfy SDKs](/zh/development/api-development/sdks)。

<CardGroup cols={3}>
  <Card title="请求头" icon="list" href="/zh/development/comfy-router/headers">
    身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。
  </Card>

  <Card title="使用 Router API" icon="code" href="/zh/development/comfy-router/api">
    模型发现、验证错误、重试与计费。
  </Card>

  <Card title="限制" icon="triangle-exclamation" href="/zh/development/comfy-router/limitations">
    Router 目前不支持的功能，以及替代方案。
  </Card>
</CardGroup>
