> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-chore-sync-comfy-api-v2-spec.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 将 Eleven Sfx V2 与 Comfy Router 配合使用

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

`elevenlabs/eleven_sfx_v2` 的 API 参考，由 Comfy Router 从 Elevenlabs 提供服务。

<h2 id="quick-start">
  快速开始
</h2>

在[你的 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_sfx_v2`

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

<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_sfx_v2",
              {
                  "duration_seconds": 5,
                  "text": "A distant rumble of thunder rolling across a valley.",
              },
          )

      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_sfx_v2", {
        duration_seconds: 5,
        text: "A distant rumble of thunder rolling across a valley.",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/elevenlabs/eleven_sfx_v2 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"duration_seconds\": 5, \"text\": \"A distant rumble of thunder rolling across a valley.\"}"
      ```
    </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_sfx_v2",
              {
                  "duration_seconds": 5,
                  "text": "A distant rumble of thunder rolling across a valley.",
              },
          )
          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_sfx_v2", {
        duration_seconds: 5,
        text: "A distant rumble of thunder rolling across a valley.",
      });
      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_sfx_v2/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"duration_seconds\": 5, \"text\": \"A distant rumble of thunder rolling across a valley.\"}"

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

## 模式

### 输入

<ParamField body="duration_seconds" type="number" required>
  将要生成的声音的时长，单位为秒。
  必须至少为 0.5，最多为 30。
  此路由上为必填：与上游 ElevenLabs API 不同（当该字段为 null 时，
  上游会推测一个最佳时长），此路由会拒绝省略该字段的请求，
  并返回 400 "Duration is required"。
  该字段保持可为 null，只是为了让显式的 null 成为一个格式良好的
  文档；它仍然会被拒绝。
  该值是请求计量所依据的数量。

  范围：`0.5` 到 `30`

  格式：`double`
</ParamField>

<ParamField body="loop" type="boolean" default="false">
  是否创建可平滑循环的音效。
  ElevenLabs 的文档说明此选项仅适用于
  'eleven\_text\_to\_sound\_v2' 模型，而此路由不予接受该模型
  （见 model\_id），因此在这里它可能没有效果。
</ParamField>

<ParamField body="model_id" type="string">
  用于声音生成的模型 ID。此路由仅接受
  'eleven\_sfx\_v2'，其他任何值都会在请求到达 ElevenLabs 之前
  被拒绝并返回 400。它不在此模式的 `required` 列表中，
  因为 Comfy Router 会从 /v2/models/elevenlabs/\{model} 的
  `{model}` 路径段填充它，所以 Router
  调用方会省略它。
</ParamField>

<ParamField body="prompt_influence" type="number">
  提示词影响越高，生成结果就越贴近提示词，
  同时生成结果的多样性也会降低。
  必须是 0 到 1 之间的值。默认为 0.3。

  范围：`0` 到 `1`

  格式：`double`
</ParamField>

<ParamField body="text" type="string" required>
  将被转换为音效的文本。
</ParamField>

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

### 输出

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

### 输出

Router 不为此模型发布输出模式。

## 示例

### 输入

```json theme={null}
{
  "duration_seconds": 5,
  "text": "A distant rumble of thunder rolling across a valley."
}
```

## 发布前须知

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>
