> ## Documentation Index
> Fetch the complete documentation index at: https://comfyuiwiki.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy RouterでHiggsfield APIキーを使う

> Higgsfield APIキーをComfy Routerに持ち込みましょう。生成はComfyのクレジットではなくHiggsfieldアカウントに課金され、他のすべてのモデルと同じエンドポイントを経由します。

ご自身の Higgsfield API キーを Comfy Router に持ち込めます。Higgsfield での生成は**お客様自身の** Higgsfield アカウントで実行され、そちらに課金されます。Comfy のクレジットには課金されないため、利用量はお客様のアカウントに計上され、Higgsfield が提示する料金やクレジットが適用されます。エンドポイントは1つ、クライアントは1つ、そして Router 上の他のすべてのモデルと同じリクエスト形状をそのまま利用できます。

<Note>
  お客様の Higgsfield 利用に関する料金および利用規約は、お客様自身のアカウント上で Higgsfield が定めるものです。最新の詳細は [Higgsfield](https://cloud.higgsfield.ai) をご覧ください。
</Note>

## 自分のキーを持ち込むと何が変わるか

|                        | 自分のComfyキー    | 自分のHiggsfieldキー    |
| ---------------------- | ------------- | ------------------ |
| 請求先                    | 自分のComfyクレジット | 自分のHiggsfieldアカウント |
| Comfyクレジットの消費          | あり            | **なし**             |
| エンドポイント、リクエストボディ、レスポンス | 同じ            | 同じ                 |

呼び出しに関するその他の点はすべて同一です。切り替えるためにコードを変更する必要はありません。キーを保存すれば、Routerがそれを使用します。

<Steps>
  <Step title="Higgsfield APIキーを取得する">
    [Higgsfield APIコンソール](https://console.higgsfield.ai)でキーを作成します。これは同社のAPI製品です（コンシューマー向けアプリとは別のログインです）。Higgsfieldはこれを **idとsecretのペア** として発行し、Comfyはそれを単一の文字列 `id:secret` として保存します。コロンはそのままにし、2つのフィールドに分割しないでください。
  </Step>

  <Step title="Comfyに保存する">
    Comfyプロフィールで[**Provider keys**](https://platform.comfy.org/profile/provider-keys)を開き、**Higgsfield** を選択して、`id:secret` の値を貼り付けます。

    キーは保存時に暗号化され、一度保存されるとAPIから返されることはありません。Routerはあなた自身の呼び出しに署名するためだけにキーを読み取ります。
  </Step>

  <Step title="Comfy APIキーを作成する">
    これはComfyに対する認証に使うキーで、Higgsfieldのキーとは別のものです。[Comfyワークスペース](https://platform.comfy.org/profile/api-keys)で作成し、次を設定します。

    ```bash theme={null}
    export COMFY_API_KEY="comfyui-..."
    ```

    APIキーはサーバーまたはローカル環境に保管してください。これらの例はターミナルまたはサーバー向けであり、ブラウザのJavaScript向けではありません。
  </Step>

  <Step title="モデルを実行する">
    以下から、選択済みのモデルに対応するコードスニペットをコピーして貼り付けてください。
  </Step>
</Steps>

## モデル

<Tabs>
  <Tab title="Kling 3.0 std">
    品質と速度のバランスが取れています。`duration` は3〜15秒を受け付けます。

    <CodeGroup>
      ```bash cURL theme={null}
      curl --max-time 660 \
        https://api.comfy.org/v2/models/higgsfield/higgsfield-kling-3-std \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
          "duration": 5,
          "aspect_ratio": "16:9",
          "cfg_scale": 0.5,
          "sound": "on"
        }'
      ```

      ```python Python theme={null}
      # Python 3.10+
      # インストール: python -m pip install "comfy-sdk>=0.3.0"

      from comfy_sdk import Comfy

      # Comfy は環境変数から COMFY_API_KEY を読み取ります。
      with Comfy() as client:
          result = client.models.run(
              "higgsfield/higgsfield-kling-3-std",
              {
                  "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
                  "duration": 5,
                  "aspect_ratio": "16:9",
                  "cfg_scale": 0.5,
                  "sound": "on",
              },
              timeout=660.0,
          )

      print("video:", result["video"]["url"])
      ```

      ```typescript TypeScript theme={null}
      // Node.js 22+
      // インストール: npm install "@comfyorg/sdk@>=0.4.0" --save-dev tsx

      import { comfy } from "@comfyorg/sdk";

      type HiggsfieldResult = { video: { url: string } };

      const { data } = await comfy.models.run<HiggsfieldResult>(
        "higgsfield/higgsfield-kling-3-std",
        {
          prompt: "A cinematic glass pavilion in a misty pine forest at sunrise",
          duration: 5,
          aspect_ratio: "16:9",
          cfg_scale: 0.5,
          sound: "on",
        },
        { timeoutMs: 660_000 },
      );

      console.log("video:", data.video.url);
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Kling 3.0 プロ">
    `std` よりも高忠実度で、本体は同じです。`duration` は 3〜15 秒を受け付けます。

    <CodeGroup>
      ```bash cURL theme={null}
      curl --max-time 660 \
        https://api.comfy.org/v2/models/higgsfield/higgsfield-kling-3-pro \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
          "duration": 5,
          "aspect_ratio": "16:9",
          "cfg_scale": 0.5,
          "sound": "on"
        }'
      ```

      ```python Python theme={null}
      # Python 3.10+
      # インストール: python -m pip install "comfy-sdk>=0.3.0"

      from comfy_sdk import Comfy

      with Comfy() as client:
          result = client.models.run(
              "higgsfield/higgsfield-kling-3-pro",
              {
                  "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
                  "duration": 5,
                  "aspect_ratio": "16:9",
                  "cfg_scale": 0.5,
                  "sound": "on",
              },
              timeout=660.0,
          )

      print("video:", result["video"]["url"])
      ```

      ```typescript TypeScript theme={null}
      // Node.js 22+
      // インストール: npm install "@comfyorg/sdk@>=0.4.0" --save-dev tsx

      import { comfy } from "@comfyorg/sdk";

      type HiggsfieldResult = { video: { url: string } };

      const { data } = await comfy.models.run<HiggsfieldResult>(
        "higgsfield/higgsfield-kling-3-pro",
        {
          prompt: "A cinematic glass pavilion in a misty pine forest at sunrise",
          duration: 5,
          aspect_ratio: "16:9",
          cfg_scale: 0.5,
          sound: "on",
        },
        { timeoutMs: 660_000 },
      );

      console.log("video:", data.video.url);
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Kling 3.0 4K">
    4K ティアで、リクエストボディは `std` および `pro` と同じです。`duration` は 3～15 秒を受け付けます。

    <CodeGroup>
      ```bash cURL theme={null}
      curl --max-time 660 \
        https://api.comfy.org/v2/models/higgsfield/higgsfield-kling-3-4k \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
          "duration": 5,
          "aspect_ratio": "16:9",
          "cfg_scale": 0.5,
          "sound": "on"
        }'
      ```

      ```python Python theme={null}
      # Python 3.10+
      # インストール: python -m pip install "comfy-sdk>=0.3.0"

      from comfy_sdk import Comfy

      with Comfy() as client:
          result = client.models.run(
              "higgsfield/higgsfield-kling-3-4k",
              {
                  "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
                  "duration": 5,
                  "aspect_ratio": "16:9",
                  "cfg_scale": 0.5,
                  "sound": "on",
              },
              timeout=660.0,
          )

      print("video:", result["video"]["url"])
      ```

      ```typescript TypeScript theme={null}
      // Node.js 22+
      // インストール: npm install "@comfyorg/sdk@>=0.4.0" --save-dev tsx

      import { comfy } from "@comfyorg/sdk";

      type HiggsfieldResult = { video: { url: string } };

      const { data } = await comfy.models.run<HiggsfieldResult>(
        "higgsfield/higgsfield-kling-3-4k",
        {
          prompt: "A cinematic glass pavilion in a misty pine forest at sunrise",
          duration: 5,
          aspect_ratio: "16:9",
          cfg_scale: 0.5,
          sound: "on",
        },
        { timeoutMs: 660_000 },
      );

      console.log("video:", data.video.url);
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Kling 3.0 turbo">
    最速の Kling ティアです。リクエストボディには `cfg_scale` と `sound` の代わりに `resolution` を含めます。`duration` は 3–15 秒を受け付けます。

    <CodeGroup>
      ```bash cURL theme={null}
      curl --max-time 660 \
        https://api.comfy.org/v2/models/higgsfield/higgsfield-kling-3-turbo \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
          "duration": 5,
          "aspect_ratio": "16:9",
          "resolution": "720p"
        }'
      ```

      ```python Python theme={null}
      # Python 3.10+
      # インストール: python -m pip install "comfy-sdk>=0.3.0"

      from comfy_sdk import Comfy

      with Comfy() as client:
          result = client.models.run(
              "higgsfield/higgsfield-kling-3-turbo",
              {
                  "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
                  "duration": 5,
                  "aspect_ratio": "16:9",
                  "resolution": "720p",
              },
              timeout=660.0,
          )

      print("video:", result["video"]["url"])
      ```

      ```typescript TypeScript theme={null}
      // Node.js 22+
      // インストール: npm install "@comfyorg/sdk@>=0.4.0" --save-dev tsx

      import { comfy } from "@comfyorg/sdk";

      type HiggsfieldResult = { video: { url: string } };

      const { data } = await comfy.models.run<HiggsfieldResult>(
        "higgsfield/higgsfield-kling-3-turbo",
        {
          prompt: "A cinematic glass pavilion in a misty pine forest at sunrise",
          duration: 5,
          aspect_ratio: "16:9",
          resolution: "720p",
        },
        { timeoutMs: 660_000 },
      );

      console.log("video:", data.video.url);
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Wan 3.0">
    参照から動画: 参照画像またはクリップを渡し、それらの使用方法を記述します。`duration` は最大30秒まで受け付けます。

    <CodeGroup>
      ```bash cURL theme={null}
      curl --max-time 660 \
        https://api.comfy.org/v2/models/higgsfield/higgsfield-wan-3 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "prompt": "Use Image 1 for the character and Video 1 for the camera movement",
          "image_urls": ["https://cdn.example.com/character.jpg"],
          "video_urls": ["https://cdn.example.com/camera-reference.mp4"],
          "duration": 8,
          "resolution": "1080p",
          "aspect_ratio": "adaptive",
          "generate_audio": true
        }'
      ```

      ```python Python theme={null}
      # Python 3.10+
      # インストール: python -m pip install "comfy-sdk>=0.3.0"

      from comfy_sdk import Comfy

      with Comfy() as client:
          result = client.models.run(
              "higgsfield/higgsfield-wan-3",
              {
                  "prompt": "Use Image 1 for the character and Video 1 for the camera movement",
                  "image_urls": ["https://cdn.example.com/character.jpg"],
                  "video_urls": ["https://cdn.example.com/camera-reference.mp4"],
                  "duration": 8,
                  "resolution": "1080p",
                  "aspect_ratio": "adaptive",
                  "generate_audio": True,
              },
              timeout=660.0,
          )

      print("video:", result["video"]["url"])
      ```

      ```typescript TypeScript theme={null}
      // Node.js 22+
      // インストール: npm install "@comfyorg/sdk@>=0.4.0" --save-dev tsx

      import { comfy } from "@comfyorg/sdk";

      type HiggsfieldResult = { video: { url: string } };

      const { data } = await comfy.models.run<HiggsfieldResult>(
        "higgsfield/higgsfield-wan-3",
        {
          prompt: "Use Image 1 for the character and Video 1 for the camera movement",
          image_urls: ["https://cdn.example.com/character.jpg"],
          video_urls: ["https://cdn.example.com/camera-reference.mp4"],
          duration: 8,
          resolution: "1080p",
          aspect_ratio: "adaptive",
          generate_audio: true,
        },
        { timeoutMs: 660_000 },
      );

      console.log("video:", data.video.url);
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## 結果の読み取り

`run` は Higgsfield 自身のターミナルドキュメントを返します。ダウンロード URL は `video.url` にあります。

```json theme={null}
{
  "status": "completed",
  "request_id": "0c4a9e17-5b82-4d66-9a3f-7c1e08b45d29",
  "video": { "url": "https://example.com/generated.mp4" }
}
```

すぐに保存してください。

```bash theme={null}
curl --fail --location "PASTE_VIDEO_URL_HERE" --output out.mp4
```

Router があなたの代わりに Higgsfield をポーリングするため、`queued` や `in_progress` があなたに届くことはありません。完了したドキュメントかエラーを受け取ります。`nsfw`、`failed`、`canceled` はターミナルな失敗であり、`failed` は `error` に詳細を含みます。

## 注意事項

* **検証は Higgsfield が呼び出される前に実行されます。** 公開されている範囲を外れたリクエストボディは、該当するフィールド名とともに `422` で返され、上流には何も送信されません。そのため、不正なリクエストによるコストは一切発生しません。
* **キーは、そのキーを保有しているモデルにのみ使用されます。** Higgsfield のキーを保存しても、Router 上の他のプロバイダーの課金方法は一切変わりません。
* すべてのモデルのリクエストスキーマとレスポンススキーマは、[Comfy Router リファレンス](/ja/development/comfy-router/reference)に記載されています。
