> ## 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 使用 FLUX 3 Max

> 通过 Comfy Router 调用 fal/flux-3-max：端点、请求结构以及 Router 返回的响应。

`fal/flux-3-max` 的 API 参考文档，由 Comfy Router 从 fal 提供。

**输入：** 文本、图像 · **输出：** 视频 + 音频

## 快速开始

在[你的 Comfy 工作区](https://platform.comfy.org/profile/api-keys?onboarding=router)中创建密钥，并将其导出为 `COMFY_API_KEY`。Python 和 TypeScript 片段使用 Comfy SDK（`pip install comfy-sdk` 和 `npm install @comfyorg/sdk`）；cURL 片段则是通过原始 HTTP 执行的同一调用。

**模型 ID：** `fal/flux-3-max`

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

**等待结果**

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

# 从环境变量中读取 COMFY_API_KEY。
# SDK 会自动创建幂等键，并在自动重试时复用它。
with Comfy() as client:
    result = client.models.run(
        "fal/flux-3-max",
        {
            "duration": 5,
            "prompt": "A red panda walks along a mossy log in a sunlit forest. Ambient birdsong.",
            "resolution": "720p",
        },
    )

print(result)
```

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

// 从环境变量中读取 COMFY_API_KEY。
// SDK 会自动创建幂等键，并在自动重试时复用它。
const { data } = await comfy.models.run("fal/flux-3-max", {
  duration: 5,
  prompt: "A red panda walks along a mossy log in a sunlit forest. Ambient birdsong.",
  resolution: "720p",
});

console.log(data);
```

```bash cURL theme={null}
curl https://api.comfy.org/v2/models/fal/flux-3-max \
  -H "X-API-Key: $COMFY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "{\"duration\": 5, \"prompt\": \"A red panda walks along a mossy log in a sunlit forest. Ambient birdsong.\", \"resolution\": \"720p\"}"
```

**排队并稍后收集**

同一个请求体，发送到 `POST https://api.comfy.org/v2/models/fal/flux-3-max/requests`。运行一经接纳，Router 就会返回 `201` 和 `request_id`；结果准备就绪后，即可从当前进程或其他进程收集。[排队投递](/zh/development/comfy-router/queue) 将介绍状态、取消和收集的完整流程。

```python Python theme={null}
import asyncio
from comfy_sdk import AsyncComfy

# 从环境变量中读取 COMFY_API_KEY。
# 每次 submit() 调用都会生成自己的 Idempotency-Key，并在自动重试时复用它。
async def main():
    async with AsyncComfy() as client:
        handle = await client.models.submit(
            "fal/flux-3-max",
            {
                "duration": 5,
                "prompt": "A red panda walks along a mossy log in a sunlit forest. Ambient birdsong.",
                "resolution": "720p",
            },
        )
        print("request_id:", handle.request_id)  # 配合模型 ID，这就是另一个进程所需的全部信息

        # 轮询直到请求完成，并等待服务器指定的 Retry-After 时长。
        async for update in handle.iter_events():
            print(update.status, update.queue_position)

        # 提供商自己的负载，与 models.run() 返回的值相同。
        # 失败或已取消的请求会在此处抛出类型化的 Router 错误。
        result = await handle.get()

    print(result)

asyncio.run(main())
```

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

// 从环境变量中读取 COMFY_API_KEY。
// 每次 submit() 调用都会生成自己的 Idempotency-Key，并在自动重试时复用它。
const handle = await comfy.models.submit("fal/flux-3-max", {
  duration: 5,
  prompt: "A red panda walks along a mossy log in a sunlit forest. Ambient birdsong.",
  resolution: "720p",
});
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);
```

```bash cURL theme={null}
# 1. 提交。Router 会返回 201，以及 request_id、status_url、response_url 和 cancel_url。
curl https://api.comfy.org/v2/models/fal/flux-3-max/requests \
  -H "X-API-Key: $COMFY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "{\"duration\": 5, \"prompt\": \"A red panda walks along a mossy log in a sunlit forest. Ambient birdsong.\", \"resolution\": \"720p\"}"

# 2. 轮询直到状态为 COMPLETED，并在每次响应中等待其指定的 Retry-After 秒数。
REQUEST_ID="<request_id from the 201 body>"
curl -i https://api.comfy.org/v2/models/fal/flux-3-max/requests/$REQUEST_ID/status \
  -H "X-API-Key: $COMFY_API_KEY"

# 3. 收集。完成时返回 200 和模型的原生输出；仍在运行时返回 202 和状态响应体。
curl https://api.comfy.org/v2/models/fal/flux-3-max/requests/$REQUEST_ID \
  -H "X-API-Key: $COMFY_API_KEY"
```

## Schema

### 输入

**aspect\_ratio** `string` (default: "auto")

生成视频的宽高比。在文本提示下，`auto` 为 16:9；否则跟随第一张图像。

可能的值：`auto`、`21:9`、`2:1`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16`

**duration** `integer` (default: 5)

生成视频的时长，单位为秒，范围为 5 至 20。fal 按该值的每秒计费。

范围：`5` 至 `20`

**generate\_audio** `boolean` (default: true)

生成同步音频。价格相同。

**prompt** `string` *required*

描述视频及其声音的文本提示。

**reasoning\_level** `string` (default: "high")

模型在生成前对提示进行推理和扩展的程度。high 更慢。价格相同。

可能的值：`low`、`high`

**resolution** `string` (default: "720p")

生成视频的分辨率。1080p 每秒费用高于 720p。

可能的值：`720p`、`1080p`

**seed** `integer`

随机种子。省略时会选择一个随机种子。

根据 Router 在 `GET /v2/models/fal/flux-3-max/openapi.json` 提供的 schema 生成，这也是请求到达提供商之前用于校验调用的同一文档。

### 输出

**seed** `integer`

用于生成的种子。

**timings** `object`

以秒为单位的耗时明细。

**video** `object` *required*

已生成的视频文件。

**video.content\_type** `string`

视频文件的 MIME 类型。

**video.duration** `number`

视频时长，单位为秒。

**video.file\_name** `string`

视频文件名。

**video.file\_size** `integer`

视频文件大小，单位为字节。

**video.fps** `number`

视频帧率。

**video.height** `integer`

视频高度，单位为像素。

**video.num\_frames** `integer`

视频的帧数。

**video.url** `string` *required*

已生成视频的 URL。

**video.width** `integer`

视频宽度，单位为像素。

## 示例

### 输入

```json theme={null}
{
  "duration": 5,
  "prompt": "A red panda walks along a mossy log in a sunlit forest. Ambient birdsong.",
  "resolution": "720p"
}
```

### 输出

```json theme={null}
{
  "seed": 42,
  "video": {
    "content_type": "video/mp4",
    "duration": 5.041666666666667,
    "file_name": "video.mp4",
    "file_size": 4404019,
    "fps": 24,
    "height": 704,
    "num_frames": 121,
    "url": "https://example.invalid/fal/flux-3-max/video.mp4",
    "width": 1280
  }
}
```

## 发布前须知

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)。

> **[请求头](/zh/development/comfy-router/headers)**
>
> 身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。

> **[使用 Router API](/zh/development/comfy-router/api)**
>
> 模型发现、验证错误、重试与计费。

> **[限制](/zh/development/comfy-router/limitations)**
>
> Router 目前不支持的功能，以及替代方案。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.