> ## 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 で Higgsfield Kling 3 Pro を使用する

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

Comfy Router が Higgsfield から提供する `higgsfield/higgsfield-kling-3-pro` の API リファレンスです。

## クイックスタート

[Comfy ワークスペース](https://platform.comfy.org/profile/api-keys?onboarding=router) でキーを作成し、`COMFY_API_KEY` としてエクスポートします。Python、TypeScript、Swift のスニペットは Comfy SDK を使用しています（`pip install comfy-sdk`、`npm install @comfyorg/sdk`、および [`ComfySwiftSDK`](https://github.com/Comfy-Org/comfy-swift-sdk) Swift パッケージ）。cURL スニペットは、同じ呼び出しを生の HTTP 経由で行います。

**モデル ID:** `higgsfield/higgsfield-kling-3-pro`

**エンドポイント:** `POST https://api.comfy.org/v2/models/higgsfield/higgsfield-kling-3-pro`

<Tabs>
  <Tab title="結果を待つ">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # 環境変数から COMFY_API_KEY を読み取ります。
      # SDK は自動的に冪等性キーを作成し、自動リトライのために再利用します。
      with Comfy() as client:
          result = client.models.run(
              "higgsfield/higgsfield-kling-3-pro",
              {
                  "aspect_ratio": "16:9",
                  "cfg_scale": 0.5,
                  "duration": 5,
                  "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
                  "sound": "on",
              },
          )

      print(result)
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // 環境変数から COMFY_API_KEY を読み取ります。
      // SDK は自動的に冪等性キーを作成し、自動リトライのために再利用します。
      const { data } = await comfy.models.run("higgsfield/higgsfield-kling-3-pro", {
        aspect_ratio: "16:9",
        cfg_scale: 0.5,
        duration: 5,
        prompt: "A cinematic glass pavilion in a misty pine forest at sunrise",
        sound: "on",
      });

      console.log(data);
      ```

      ```swift Swift theme={null}
      import Foundation
      import ComfySwiftSDK

      // 環境変数から COMFY_API_KEY を読み取ります。
      // SDK は呼び出しごとに冪等性キーを生成し、自動リトライのために再利用します。
      let client = ComfyCloudClient(apiKey: ProcessInfo.processInfo.environment["COMFY_API_KEY"]!)
      let result = try await client.models.run(
          "higgsfield/higgsfield-kling-3-pro",
          input: [
              "aspect_ratio": "16:9",
              "cfg_scale": 0.5,
              "duration": 5,
              "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
              "sound": "on",
          ]
      )

      print(result.output)
      ```

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

  <Tab title="キューに送信して後で収集する">
    同じボディを `POST https://api.comfy.org/v2/models/higgsfield/higgsfield-kling-3-pro/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備ができ次第、このプロセスまたは別のプロセスから収集されます。[キューの配信](/ja/development/comfy-router/queue)では、ステータス、キャンセル、収集の流れを説明します。

    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # 環境から COMFY_API_KEY を読み取ります。
      # 各 submit() 呼び出しは独自の Idempotency-Key を発行し、自動リトライのために再利用します。
      with Comfy() as client:
          handle = client.models.submit(
              "higgsfield/higgsfield-kling-3-pro",
              {
                  "aspect_ratio": "16:9",
                  "cfg_scale": 0.5,
                  "duration": 5,
                  "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
                  "sound": "on",
              },
          )
          print("request_id:", handle.request_id)  # モデル ID と合わせて、別のプロセスが必要とする情報はこれだけです

          # リクエストが完了するまでポーリングし、サーバーが指定する Retry-After の秒数だけ待機します。
          for update in handle.iter_events():
              print(update.status, update.queue_position)

          # プロバイダー自身のペイロードで、models.run() が返す値と同じです。
          # 失敗またはキャンセル済みのリクエストは、ここで型付きの Router エラーを送出します。
          result = handle.get()

      print(result)
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // 環境から COMFY_API_KEY を読み取ります。
      // 各 submit() 呼び出しは独自の Idempotency-Key を発行し、自動リトライのために再利用します。
      const handle = await comfy.models.submit("higgsfield/higgsfield-kling-3-pro", {
        aspect_ratio: "16:9",
        cfg_scale: 0.5,
        duration: 5,
        prompt: "A cinematic glass pavilion in a misty pine forest at sunrise",
        sound: "on",
      });
      console.log("requestId:", handle.requestId); // モデル ID と合わせて、別のプロセスが必要とする情報はこれだけです

      // リクエストが完了するまでポーリングし、サーバーが指定する Retry-After の秒数だけ待機します。
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      // models.run() が返す結果と同じです。失敗またはキャンセル済みのリクエストはここで reject されます。
      const result = await handle.get();

      console.log(result.data);
      ```

      ```swift Swift theme={null}
      import Foundation
      import ComfySwiftSDK

      // 環境から COMFY_API_KEY を読み取ります。
      // 各 submit() 呼び出しは独自の Idempotency-Key を発行し、自動リトライのために再利用します。
      let client = ComfyCloudClient(apiKey: ProcessInfo.processInfo.environment["COMFY_API_KEY"]!)
      let handle = try await client.models.submit(
          "higgsfield/higgsfield-kling-3-pro",
          input: [
              "aspect_ratio": "16:9",
              "cfg_scale": 0.5,
              "duration": 5,
              "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
              "sound": "on",
          ]
      )
      print("requestId:", handle.requestId)  // モデル ID と合わせて、別のプロセスが必要とする情報はこれだけです

      // リクエストが完了するまでポーリングし、サーバーが指定する Retry-After の秒数だけ待機します。
      for try await update in handle.events() {
          print(update.state.rawValue, update.queuePosition.map(String.init) ?? "unknown")
      }

      // プロバイダー自身のペイロードで、models.run() が返す値と同じです。
      // 失敗またはキャンセル済みのリクエストは、ここで型付きの Router エラーをスローします。
      let result = try await handle.result()

      print(result.output)
      ```

      ```bash cURL theme={null}
      # 1. 送信します。Router は request_id、status_url、response_url、cancel_url とともに 201 を返します。
      curl https://api.comfy.org/v2/models/higgsfield/higgsfield-kling-3-pro/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"aspect_ratio\": \"16:9\", \"cfg_scale\": 0.5, \"duration\": 5, \"prompt\": \"A cinematic glass pavilion in a misty pine forest at sunrise\", \"sound\": \"on\"}"

      # 2. ステータスが COMPLETED になるまでポーリングし、各レスポンスが指定する Retry-After の秒数だけ待機します。
      REQUEST_ID="<request_id from the 201 body>"
      curl -i https://api.comfy.org/v2/models/higgsfield/higgsfield-kling-3-pro/requests/$REQUEST_ID/status \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. 収集します。モデル固有の出力とともに 200、まだ実行中ならステータスボディとともに 202 を返します。
      curl https://api.comfy.org/v2/models/higgsfield/higgsfield-kling-3-pro/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### Input

<ParamField body="aspect_ratio" type="string" default="&#x22;16:9&#x22;">
  出力のアスペクト比。

  指定可能な値: `16:9`、`9:16`、`1:1`
</ParamField>

<ParamField body="cfg_scale" type="number" default="0.5">
  生成がプロンプトにどれだけ強く従うか。Higgsfield は 0〜1 を 0.01 刻みとしてドキュメント化していますが、ここで宣言されているのは 0〜1 の範囲のみです。`multipleOf: 0.01` はバイナリ浮動小数点で評価されるため、0.3 のようなごく普通の値を拒否してしまいます。したがって、より細かい値は拒否されるのではなく受け入れられて転送されます。これは `prompt` が宣言していない文字数上限に但し書きを付けているのと同じ扱いです。

  範囲: `0` から `1`
</ParamField>

<ParamField body="duration" type="integer" default="5">
  出力の再生時間（秒単位）。サポートされる範囲: 3〜15。

  範囲: `3` から `15`
</ParamField>

<ParamField body="elements" type="string[]">
  生成をまたいで被写体の一貫性を保つための、再利用可能な Kling エレメント ID。
</ParamField>

<ParamField body="multi_prompt" type="object[]">
  順序付けられたショット定義。`multi_shots` が true のときに使用します。1〜6 ショットで、ショットごとの再生時間はタスク自体の合計再生時間によって制限されますが、それはここでは表現できません。
</ParamField>

<ParamField body="multi_prompt[].duration" type="integer">
  このショットの再生時間（秒単位）。1〜15。全ショットの合計はタスクの合計再生時間を超えてはなりませんが、JSON Schema ではそれを表現できません。Higgsfield がこれを強制します。

  範囲: `1` から `15`
</ParamField>

<ParamField body="multi_prompt[].prompt" type="string">
  このショットのプロンプト。Higgsfield は 512 文字の上限をドキュメント化しています。
</ParamField>

<ParamField body="multi_shots" type="boolean" default="false">
  マルチショットシーケンスを有効にします。true の場合、`multi_prompt` がショットごとの定義を保持します。
</ParamField>

<ParamField body="prompt" type="string">
  目的の出力を記述するプロンプト。Higgsfield のドキュメントによると、Kling は最初の 2,500 文字までを使用し、それを超える部分は切り捨てられます。そのため maxLength は宣言されておらず、上限を超える本文は拒否されずに受け入れられます。
</ParamField>

<ParamField body="sound" type="string" default="&#x22;on&#x22;">
  生成されるサウンドを有効または無効にします。

  指定可能な値: `on`、`off`
</ParamField>

Router が `GET /v2/models/higgsfield/higgsfield-kling-3-pro/openapi.json` で提供するスキーマから生成されています。これは、リクエストがプロバイダーに到達する前に呼び出しを検証する際に使用するのと同じドキュメントです。

### Output

<ResponseField name="cancel_url" type="string">
  処理が開始される前にリクエストをキャンセルするために使用する絶対 URL。
</ResponseField>

<ResponseField name="error" type="string">
  失敗の詳細。`status` が `failed` のときに設定されます。
</ResponseField>

<ResponseField name="request_id" type="string" required>
  ポーリング、キャンセル、サポートに使用される安定した識別子。
</ResponseField>

<ResponseField name="status" type="string" required>
  現在のリクエスト状態。

  指定可能な値: `queued`、`in_progress`、`nsfw`、`failed`、`completed`、`canceled`
</ResponseField>

<ResponseField name="status_url" type="string">
  リクエストがターミナル状態に達するまでポーリングするための絶対 URL。
</ResponseField>

<ResponseField name="video" type="object">
  1 つの Higgsfield メディア出力。
</ResponseField>

<ResponseField name="video.url" type="string" required>
  生成済みメディアのダウンロード URL。
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "aspect_ratio": "16:9",
  "cfg_scale": 0.5,
  "duration": 5,
  "prompt": "A cinematic glass pavilion in a misty pine forest at sunrise",
  "sound": "on"
}
```

### 出力

```json theme={null}
{
  "cancel_url": "https://api.higgsfield.ai/requests/d7e6c0f3-6699-4f6c-bb45-2ad7fd9158ff/cancel",
  "request_id": "d7e6c0f3-6699-4f6c-bb45-2ad7fd9158ff",
  "status": "completed",
  "status_url": "https://api.higgsfield.ai/requests/d7e6c0f3-6699-4f6c-bb45-2ad7fd9158ff/status",
  "video": {
    "url": "https://example.invalid/higgsfield/higgsfield-kling-3-pro/generated.mp4"
  }
}
```

## 出荷前の確認

SDK は `Idempotency-Key` を生成し、自動リトライで再利用します。手動リトライでは元のキーを再利用してください。Router は最大 10 分間接続を保持できます。

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

上記のフィールド説明に記載されているサイズ制限は、プロバイダーの仕様から引用した、そのフィールドに対するプロバイダー自身の上限です。Router はリクエスト本文全体に対して別の上限を適用し、base64 エンコードされたメディアもこれにカウントされます。[リクエスト本文のサイズ](/ja/development/comfy-router/limitations) を参照してください。

このページは、Comfy Router 経由で呼び出す 1 つのパートナーモデルについて説明しています。同じ `comfy-sdk` / `@comfyorg/sdk` パッケージには、Comfy Cloud 上で ComfyUI のワークフローグラフ全体を実行するための 2 つ目のクライアントも含まれています: `Comfy(api_key=...)` / `new Comfy({ apiKey })`、および `client.workflows`、`client.assets`、`client.jobs`。[Comfy SDKs](/ja/development/api-development/sdks) を参照してください。

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

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

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