> ## 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.

# 将 H3 Max Turbo 与 Comfy Router 搭配使用

> 通过 Comfy Router 调用 fal/h3-max-turbo：端点、请求形状以及 Router 返回的响应。

由 Comfy Router 从 fal 提供的 `fal/h3-max-turbo` API 参考文档。

## 快速开始

在[你的 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：** `fal/h3-max-turbo`

**端点：** `POST https://api.comfy.org/v2/models/fal/h3-max-turbo`

<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(
              "fal/h3-max-turbo",
              {
                  "duration": 5,
                  "prompt": "a red fox running through a snowy forest",
                  "prompt_expansion_mode": "balanced",
                  "resolution": "480P",
              },
          )

      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("fal/h3-max-turbo", {
        duration: 5,
        prompt: "a red fox running through a snowy forest",
        prompt_expansion_mode: "balanced",
        resolution: "480P",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/fal/h3-max-turbo \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"duration\": 5, \"prompt\": \"a red fox running through a snowy forest\", \"prompt_expansion_mode\": \"balanced\", \"resolution\": \"480P\"}"
      ```
    </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(
              "fal/h3-max-turbo",
              {
                  "duration": 5,
                  "prompt": "a red fox running through a snowy forest",
                  "prompt_expansion_mode": "balanced",
                  "resolution": "480P",
              },
          )
          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("fal/h3-max-turbo", {
        duration: 5,
        prompt: "a red fox running through a snowy forest",
        prompt_expansion_mode: "balanced",
        resolution: "480P",
      });
      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/fal/h3-max-turbo/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"duration\": 5, \"prompt\": \"a red fox running through a snowy forest\", \"prompt_expansion_mode\": \"balanced\", \"resolution\": \"480P\"}"

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

## Schema

### 输入

<ParamField body="aspect_ratio" type="string" default="&#x22;16:9&#x22;">
  宽高比：21:9、16:9、4:3、1:1、3:4 或 9:16。
</ParamField>

<ParamField body="duration" type="integer" default="5">
  已生成视频的时长，单位为秒。
</ParamField>

<ParamField body="enable_safety_checker" type="boolean" default="true">
  是否启用安全检查器。
</ParamField>

<ParamField body="prompt" type="string" required>
  用于视频生成的文本提示词。
</ParamField>

<ParamField body="prompt_expansion_mode" type="string" required>
  生成之前重写提示词的投入程度：balanced 或 quality。
</ParamField>

<ParamField body="resolution" type="string" default="&#x22;768P&#x22;">
  已生成视频的分辨率：480P 或 768P。
</ParamField>

<ParamField body="seed" type="integer">
  随机种子。省略时会随机选择一个种子。
</ParamField>

<ParamField body="sync_mode" type="boolean">
  以 base64 而非 CDN URL 的形式返回生成的视频。
</ParamField>

由 Router 在 `GET /v2/models/fal/h3-max-turbo/openapi.json` 提供的 schema 生成，这也是请求到达提供商之前 Router 用来校验调用的同一份文档。

### 输出

<ResponseField name="expanded_prompt" type="string">
  扩展之后的提示词，即发送给模型的提示词。
</ResponseField>

<ResponseField name="timings" type="object">
  端到端耗时明细（秒）。
</ResponseField>

<ResponseField name="video" type="object" required>
  已生成的视频文件。
</ResponseField>

<ResponseField name="video.content_type" type="string">
  视频文件的 MIME 类型。
</ResponseField>

<ResponseField name="video.file_name" type="string">
  视频文件的名称。
</ResponseField>

<ResponseField name="video.file_size" type="integer">
  视频文件的大小，单位为字节。
</ResponseField>

<ResponseField name="video.url" type="string">
  已生成视频的 URL。
</ResponseField>

## 示例

### 输入

```json theme={null}
{
  "duration": 5,
  "prompt": "a red fox running through a snowy forest",
  "prompt_expansion_mode": "balanced",
  "resolution": "480P"
}
```

### 输出

```json theme={null}
{
  "expanded_prompt": "a single red maple leaf falling onto still water, cinematic, 4k",
  "timings": {
    "inference": 42.5
  },
  "video": {
    "content_type": "video/mp4",
    "file_name": "output.mp4",
    "file_size": 4194304,
    "url": "https://example.invalid/fal/minimax/h3-max/output.mp4"
  }
}
```

## 发布前须知

SDK 会生成 `Idempotency-Key` 并在自动重试中复用它。手动重试时，请复用原始 key。Router 最长可保持连接 10 分钟。

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

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

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

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