> ## 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 调用 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)中创建一个密钥，并将其导出为 `COMFY_API_KEY`。Python 和 TypeScript 代码片段使用 Comfy SDK（`pip install comfy-sdk`、`npm install @comfyorg/sdk`）；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

      # 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(
              "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";

      // 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("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);
      ```

      ```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

      # 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(
              "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)  # 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("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); // 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/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. 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/ltx/ltx-2-5-pro/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/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 在调用提供商之前就拒绝了输入。生成的资源请及时下载，因为[结果链接会过期](/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>
