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

# 将 Eleven V3 与 Comfy Router 配合使用

> 通过 Comfy Router 调用 elevenlabs/eleven_v3：端点、请求结构以及 Router 返回的响应。

`elevenlabs/eleven_v3` 的 API 参考文档，由 Comfy Router 从 Elevenlabs 提供。

## 快速开始

在[你的 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：** `elevenlabs/eleven_v3`

**端点：** `POST https://api.comfy.org/v2/models/elevenlabs/eleven_v3`

<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(
              "elevenlabs/eleven_v3",
              {
                  "inputs": [
                      {
                          "text": "Hello from Comfy Router.",
                          "voice_id": "21m00Tcm4TlvDq8ikWAM",
                      },
                  ],
              },
          )

      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("elevenlabs/eleven_v3", {
        inputs: [
          {
            text: "Hello from Comfy Router.",
            voice_id: "21m00Tcm4TlvDq8ikWAM",
          },
        ],
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/elevenlabs/eleven_v3 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"inputs\": [{\"text\":\"Hello from Comfy Router.\",\"voice_id\":\"21m00Tcm4TlvDq8ikWAM\"}]}"
      ```
    </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(
              "elevenlabs/eleven_v3",
              {
                  "inputs": [
                      {
                          "text": "Hello from Comfy Router.",
                          "voice_id": "21m00Tcm4TlvDq8ikWAM",
                      },
                  ],
              },
          )
          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("elevenlabs/eleven_v3", {
        inputs: [
          {
            text: "Hello from Comfy Router.",
            voice_id: "21m00Tcm4TlvDq8ikWAM",
          },
        ],
      });
      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/elevenlabs/eleven_v3/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"inputs\": [{\"text\":\"Hello from Comfy Router.\",\"voice_id\":\"21m00Tcm4TlvDq8ikWAM\"}]}"

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

## Schema

### 输入

<ParamField body="apply_text_normalization" type="string" default="&#x22;auto&#x22;">
  通过三种模式控制文本归一化：
  'auto' - 系统自动决定是否应用文本归一化
  'on' - 始终应用文本归一化
  'off' - 跳过文本归一化

  可选值：`auto`、`on`、`off`
</ParamField>

<ParamField body="inputs" type="object[]" required>
  对话输入列表，每一项包含将被转换为语音的文本和语音 ID。
  唯一语音 ID 的最大数量为 10。
</ParamField>

<ParamField body="inputs[].text" type="string" required>
  要转换为语音的文本。
</ParamField>

<ParamField body="inputs[].voice_id" type="string" required>
  用于生成的语音 ID。
</ParamField>

<ParamField body="language_code" type="string">
  语言代码（ISO 639-1），用于为模型和文本归一化强制指定一种语言。
  如果模型不支持所提供的语言代码，将返回错误。
</ParamField>

<ParamField body="model_id" type="string">
  将要使用的模型标识符。此路由仅接受
  'eleven\_v3'，不接受其他任何值；任何其他值都会在请求到达
  ElevenLabs 之前以 400 拒绝。
  上游 ElevenLabs 关于通过 GET /v1/models 查询
  可用模型集合的建议并不适用于此路由，因为此路由只提供一个模型。
  它不在本 schema 的 `required` 列表中，因为 Comfy Router
  会从 /v2/models/elevenlabs/\{model} 的 `{model}` 路径段中
  填充该值，因此 Router 调用方会省略它。
</ParamField>

<ParamField body="pronunciation_dictionary_locators" type="object[]">
  要应用于文本的发音词典定位符列表（id、version\_id）。
  它们将按顺序应用。每次请求最多可使用 3 个定位符。
</ParamField>

<ParamField body="pronunciation_dictionary_locators[].pronunciation_dictionary_id" type="string" required>
  发音词典的 ID
</ParamField>

<ParamField body="pronunciation_dictionary_locators[].version_id" type="string" required>
  发音词典的版本 ID
</ParamField>

<ParamField body="seed" type="integer">
  如果指定，我们的系统将尽最大努力进行确定性采样。
  使用相同种子和参数的重复请求应返回相同的结果。
  必须是 0 到 4294967295 之间的整数。

  范围：`0` 到 `4294967295`
</ParamField>

<ParamField body="settings" type="object">
  控制对话生成的设置
</ParamField>

<ParamField body="settings.stability" type="number" default="0.5">
  决定语音的稳定程度以及每次生成之间的随机性。
  较低的值会为语音带来更广泛的情感范围。
  较高的值可能导致语音单调、情感表达有限。

  格式：`double`
</ParamField>

根据 Router 在 `GET /v2/models/elevenlabs/eleven_v3/openapi.json` 提供的 schema 生成，该文档与 Router 在请求到达提供商之前用于校验调用的文档相同。

### 输出

<ResponseField name="*/*" type="string (binary)">
  原始音频字节。Content-Type 和编码遵循所请求的 output\_format，并从 ElevenLabs 原样转发。示例是二进制主体的占位符，不是 JSON 或 base64。
</ResponseField>

### 输出

Router 不发布此模型的输出 schema。

## 示例

### 输入

```json theme={null}
{
  "inputs": [
    {
      "text": "Hello from Comfy Router.",
      "voice_id": "21m00Tcm4TlvDq8ikWAM"
    }
  ]
}
```

## 发布前须知

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>
