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

# 使用 Comfy Router 调用 LTX 2.5 Pro

> 通过 Comfy Router 调用 ltx/ltx-2-5-pro：端点、请求结构以及 Router 返回的响应。

`ltx/ltx-2-5-pro` 的 API 参考文档，由 Comfy Router 从 LTX 提供。

## 快速开始

在[你的 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：** `ltx/ltx-2-5-pro`

**端点：** `POST https://api.comfy.org/v2/models/ltx/ltx-2-5-pro`

<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(
              "ltx/ltx-2-5-pro",
              {
                  "duration": 2,
                  "fps": 24,
                  "generate_audio": False,
                  "prompt": "A single red maple leaf resting on a plain white background.",
                  "resolution": "1280x720",
              },
          )

      print(result)
      ```

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

      // 从环境变量中读取 COMFY_API_KEY。
      // SDK 会自动创建幂等键，并在自动重试时复用它。
      const { data } = await comfy.models.run("ltx/ltx-2-5-pro", {
        duration: 2,
        fps: 24,
        generate_audio: false,
        prompt: "A single red maple leaf resting on a plain white background.",
        resolution: "1280x720",
      });

      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(
          "ltx/ltx-2-5-pro",
          input: [
              "duration": 2,
              "fps": 24,
              "generate_audio": false,
              "prompt": "A single red maple leaf resting on a plain white background.",
              "resolution": "1280x720",
          ]
      )

      print(result.output)
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/ltx/ltx-2-5-pro \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"duration\": 2, \"fps\": 24, \"generate_audio\": false, \"prompt\": \"A single red maple leaf resting on a plain white background.\", \"resolution\": \"1280x720\"}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="先排队，稍后收集">
    相同的请求体，发送至 `POST https://api.comfy.org/v2/models/ltx/ltx-2-5-pro/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(
              "ltx/ltx-2-5-pro",
              {
                  "duration": 2,
                  "fps": 24,
                  "generate_audio": False,
                  "prompt": "A single red maple leaf resting on a plain white background.",
                  "resolution": "1280x720",
              },
          )
          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("ltx/ltx-2-5-pro", {
        duration: 2,
        fps: 24,
        generate_audio: false,
        prompt: "A single red maple leaf resting on a plain white background.",
        resolution: "1280x720",
      });
      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(
          "ltx/ltx-2-5-pro",
          input: [
              "duration": 2,
              "fps": 24,
              "generate_audio": false,
              "prompt": "A single red maple leaf resting on a plain white background.",
              "resolution": "1280x720",
          ]
      )
      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/ltx/ltx-2-5-pro/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"duration\": 2, \"fps\": 24, \"generate_audio\": false, \"prompt\": \"A single red maple leaf resting on a plain white background.\", \"resolution\": \"1280x720\"}"

      # 2. 轮询直到状态为 COMPLETED，每次响应都会指明需要等待的 Retry-After 秒数。
      REQUEST_ID="<request_id from the 201 body>"
      curl -i https://api.comfy.org/v2/models/ltx/ltx-2-5-pro/requests/$REQUEST_ID/status \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. 收集结果。仍在运行时返回 202 和状态响应体；完成后返回 200 和模型的原始输出。
      curl https://api.comfy.org/v2/models/ltx/ltx-2-5-pro/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### 输入

<ParamField body="duration" type="integer" required>
  视频时长，单位为秒（最大值取决于分辨率和帧率）

  可选值：`2`、`3`、`4`、`5`、`6`、`8`、`10`、`12`、`14`、`16`、`18`、`20`
</ParamField>

<ParamField body="fps" type="integer" default="25">
  帧率，单位为帧每秒

  可选值：`24`、`25`、`48`、`50`
</ParamField>

<ParamField body="generate_audio" type="boolean" default="true">
  为视频生成音频
</ParamField>

<ParamField body="model" type="string">
  用于生成的模型。在 Comfy Router 路由 `POST /v2/models/ltx/{model}` 上，该字段由路径提供，可以省略。LTX 在此操作上提供的拼写，即 Comfy Router 以 `ltx/<model>` 寻址的集合，为 ltx-2-5-fast 和 ltx-2-5-pro；此处将其直接写出，而不是限定为 enum，原因见上方注释。每个模型允许哪些分辨率，请参见下方 `resolution` 属性上的 `x-comfy-model-resolutions` 矩阵。
</ParamField>

<ParamField body="prompt" type="string" required>
  描述所需视频内容的文本提示词
</ParamField>

<ParamField body="resolution" type="string" required>
  输出视频分辨率。enum 是全部模型的并集；支持的集合按模型而异。支持的组合：ltx-2-5-fast：1280x720、720x1280、1920x1080、1080x1920、2560x1440、1440x2560、3840x2160、2160x3840；ltx-2-5-pro：1280x720、720x1280、1920x1080、1080x1920。其他（模型，分辨率）组合不受支持；v2 路由会以 400 拒绝这些请求。同一矩阵以机器可读的形式发布在该属性的 x-comfy-model-resolutions 扩展中。

  可选值：`1280x720`、`720x1280`、`1920x1080`、`1080x1920`、`2560x1440`、`1440x2560`、`3840x2160`、`2160x3840`
</ParamField>

本文档根据 Router 在 `GET /v2/models/ltx/ltx-2-5-pro/openapi.json` 提供的 schema 生成，Router 在请求到达提供商之前，正是依据同一份文档校验调用。

### 输出

<ResponseField name="completed_at" type="string">
  任务完成时间戳（ISO 8601）
</ResponseField>

<ResponseField name="created_at" type="string">
  任务创建时间戳（ISO 8601）
</ResponseField>

<ResponseField name="error" type="object">
  当 status 为 failed 时存在
</ResponseField>

<ResponseField name="error.message" type="string" />

<ResponseField name="error.type" type="string" />

<ResponseField name="id" type="string">
  唯一任务标识符
</ResponseField>

<ResponseField name="result" type="object">
  当 status 为 completed 时存在；输出 URL 在完成后 24 小时过期
</ResponseField>

<ResponseField name="result.video_url" type="string">
  已生成视频的 URL
</ResponseField>

<ResponseField name="status" type="string">
  任务状态（pending、processing、completed、failed）
</ResponseField>

## 示例

### 输入

```json theme={null}
{
  "duration": 2,
  "fps": 24,
  "generate_audio": false,
  "prompt": "A single red maple leaf resting on a plain white background.",
  "resolution": "1280x720"
}
```

### 输出

```json theme={null}
{
  "completed_at": "2026-01-01T00:02:10Z",
  "created_at": "2026-01-01T00:00:00Z",
  "id": "3f7a1b28-5c0d-4e91-8a6f-1b2c3d4e5f60",
  "result": {
    "video_url": "https://example.invalid/ltx/generated.mp4"
  },
  "status": "completed"
}
```

## 发布前须知

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>
