> ## 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 で Eleven Sfx V2 を使う

> Comfy Router 経由で elevenlabs/eleven_sfx_v2 を呼び出します: エンドポイント、リクエストの形状、Router が返すレスポンスについて説明します。

`elevenlabs/eleven_sfx_v2` の API Reference。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_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 以下である必要があります。
  このルートでは必須です。フィールドが null の場合に最適な長さを推測する上流の ElevenLabs API とは異なり、このルートは省略されたリクエストを 400 "Duration is required" で拒否します。
  このフィールドが nullable のままであるのは、明示的な 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">
  prompt influence を高くすると、生成結果がプロンプトに沿いやすくなる一方で、生成のばらつきが小さくなります。
  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` を生成し、自動リトライで再利用します。手動リトライでは元のキーを再利用してください。Router は最大 10 分間接続を保持できます。

リクエストが失敗すると、Router は理由を示す `X-Comfy-Error-Type` レスポンスヘッダーを送信します。`422` は、プロバイダーを呼び出す前に Router が入力を拒否したことを意味します。生成されたアセットは [結果 URL の有効期限](/ja/development/comfy-router/reference#結果アセット) があるため、早めにダウンロードしてください。

<CardGroup cols={3}>
  <Card title="ヘッダー" icon="list" href="/ja/development/comfy-router/quickstart">
    認証、冪等性、リクエスト ID、エラー分類、リトライ間隔、支出上限。
  </Card>

  <Card title="Router API の利用" icon="code" href="/ja/development/comfy-router/quickstart">
    モデルの検出、バリデーションエラー、リトライ、課金。
  </Card>

  <Card title="制限事項" icon="triangle-exclamation" href="/ja/development/comfy-router/limitations">
    Router が現在対応していないことと、代替手段。
  </Card>
</CardGroup>
