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

# Kling V3 Omni を Comfy Router で使用する

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

Comfy Router が Kling から提供する `kling/kling-v3-omni` の API リファレンス。

## クイックスタート

[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:** `kling/kling-v3-omni`

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

<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(
              "kling/kling-v3-omni",
              {
                  "aspect_ratio": "16:9",
                  "duration": "5",
                  "mode": "pro",
                  "prompt": "A paper boat drifting down a rain-soaked street at dusk.",
              },
          )

      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("kling/kling-v3-omni", {
        aspect_ratio: "16:9",
        duration: "5",
        mode: "pro",
        prompt: "A paper boat drifting down a rain-soaked street at dusk.",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/kling/kling-v3-omni \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"aspect_ratio\": \"16:9\", \"duration\": \"5\", \"mode\": \"pro\", \"prompt\": \"A paper boat drifting down a rain-soaked street at dusk.\"}"
      ```
    </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(
              "kling/kling-v3-omni",
              {
                  "aspect_ratio": "16:9",
                  "duration": "5",
                  "mode": "pro",
                  "prompt": "A paper boat drifting down a rain-soaked street at dusk.",
              },
          )
          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("kling/kling-v3-omni", {
        aspect_ratio: "16:9",
        duration: "5",
        mode: "pro",
        prompt: "A paper boat drifting down a rain-soaked street at dusk.",
      });
      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/kling/kling-v3-omni/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"aspect_ratio\": \"16:9\", \"duration\": \"5\", \"mode\": \"pro\", \"prompt\": \"A paper boat drifting down a rain-soaked street at dusk.\"}"

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

## スキーマ

### 入力

<ParamField body="aspect_ratio" type="string">
  生成されるビデオフレームのアスペクト比（幅:高さ）。先頭フレーム参照またはビデオ編集機能を使用しない場合に必須です。

  取り得る値: `16:9`, `9:16`, `1:1`
</ParamField>

<ParamField body="callback_url" type="string (uri)">
  このタスクの結果を受け取るコールバック通知先アドレス。設定すると、タスクのステータスが変化した際にサーバーが能動的に通知します。

  フォーマット: `uri`
</ParamField>

<ParamField body="duration" type="string" default="&#x22;5&#x22;">
  ビデオの長さ（秒）。ビデオ編集機能（refer\_type: base）を使用する場合、出力の再生時間は入力ビデオと同じになり、このパラメータは無効です。

  取り得る値: `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `13`, `14`, `15`
</ParamField>

<ParamField body="element_list" type="object[]">
  エレメントIDの設定に基づく参照エレメントリスト。
</ParamField>

<ParamField body="element_list[].element_id" type="integer" required>
  エレメントID

  フォーマット: `int64`
</ParamField>

<ParamField body="external_task_id" type="string">
  カスタムタスクID。単一のユーザーアカウント内で一意である必要があります。
</ParamField>

<ParamField body="image_list" type="object[]">
  参照画像リスト。エレメント、シーン、スタイルなどの参照画像を含めることができ、また先頭または最後のフレームとしてビデオを生成するために使用できます。
</ParamField>

<ParamField body="image_list[].image_url" type="string">
  画像のBase64エンコードまたは画像URL（アクセス可能であることを確認してください）。サポートされるフォーマットには .jpg/.jpeg/.png が含まれます。ファイルサイズは10MBを超えることはできません。幅と高さの寸法は300px以上、アスペクト比は1:2.5～2.5:1の範囲である必要があります。
</ParamField>

<ParamField body="image_list[].type" type="string">
  画像が先頭フレームか最後のフレームかを示します。first\_frame は先頭フレーム、end\_frame は最後のフレームです。現在、最後のフレームのみはサポートされていません。

  取り得る値: `first_frame`, `end_frame`
</ParamField>

<ParamField body="mode" type="string" default="&#x22;pro&#x22;">
  ビデオ生成モード。std: スタンダードモード、720Pビデオを生成、コスト効率が良い。pro: プロフェッショナルモード、1080Pビデオを生成、より高品質なビデオ出力。

  取り得る値: `pro`, `std`
</ParamField>

<ParamField body="model_name" type="string">
  モデル名。Comfy Routerを使用する場合は省略するかnullを送信してください。モデルはリクエストパスによって選択されます。名前を指定する場合は、そのパスと一致する必要があります。
</ParamField>

<ParamField body="multi_prompt" type="object[]">
  各ストーリーボードに関する情報（プロンプトや再生時間など）。最大6つのストーリーボードをサポートし、最小1つです。multi\_shot が true で shot\_type が customize の場合に必須です。
</ParamField>

<ParamField body="multi_prompt[].duration" type="string">
  このストーリーボードの再生時間（秒）。タスク全体の再生時間を超えてはならず、1未満であってはなりません。すべてのストーリーボードの再生時間の合計は、タスク全体の再生時間と等しくなります。
</ParamField>

<ParamField body="multi_prompt[].index" type="integer">
  ショットの順序番号
</ParamField>

<ParamField body="multi_prompt[].prompt" type="string">
  このストーリーボードのプロンプトワード。最大長512文字。
</ParamField>

<ParamField body="multi_shot" type="boolean" default="false">
  マルチショットビデオを生成するかどうか。true の場合、prompt パラメータは無効です。false の場合、shot\_type および multi\_prompt パラメータは無効です。
</ParamField>

<ParamField body="prompt" type="string">
  テキストプロンプトワード。ポジティブおよびネガティブな記述を含めることができます。2,500文字を超えてはなりません。\<\<\<>>> の形式でエレメント、画像、ビデオを指定できます。例: \<\<element\_1>>、\<\<\<image\_1>>>、\<\<\<video\_1>>>。
</ParamField>

<ParamField body="shot_type" type="string">
  ストーリーボード方法。multi\_shot パラメータが true に設定されている場合に必須です。

  取り得る値: `customize`, `intelligence`
</ParamField>

<ParamField body="sound" type="string" default="&#x22;off&#x22;">
  ビデオ生成時に同時にサウンドを生成するかどうか。

  取り得る値: `on`, `off`
</ParamField>

<ParamField body="video_list" type="object[]">
  参照ビデオリスト。特徴の参照ビデオとして、または編集対象のビデオとして使用できます。デフォルトでは編集対象のビデオです。
</ParamField>

<ParamField body="video_list[].keep_original_sound" type="string">
  ビデオのオリジナルサウンドを保持するかどうか。yes は保持、no は保持しないことを示します。

  取り得る値: `yes`, `no`
</ParamField>

<ParamField body="video_list[].refer_type" type="string">
  参照ビデオタイプ。feature は特徴参照ビデオ、base は編集対象のビデオです。

  取り得る値: `feature`, `base`
</ParamField>

<ParamField body="video_list[].video_url" type="string" required>
  アップロードされたビデオのURL。.mp4/.mov フォーマットのみサポートされます。再生時間は3～10秒。解像度は720px～2160pxである必要があります。24～60 fpsのフレームレートをサポートします。アップロードできるビデオは1つだけで、サイズは200MBを超えてはなりません。
</ParamField>

<ParamField body="watermark_info" type="object">
  ウォーターマーク付きの結果を同時に生成するかどうか。現時点ではカスタムウォーターマークはサポートされていません。
</ParamField>

<ParamField body="watermark_info.enabled" type="boolean">
  true はウォーターマークを生成、false は生成しないことを意味します。
</ParamField>

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

### 出力

<ResponseField name="code" type="integer">
  エラーコード
</ResponseField>

<ResponseField name="data" type="object" />

<ResponseField name="data.created_at" type="integer">
  タスク作成時間、Unixタイムスタンプ（ミリ秒）
</ResponseField>

<ResponseField name="data.final_unit_deduction" type="string">
  タスクの消費ユニット数
</ResponseField>

<ResponseField name="data.task_id" type="string">
  タスクID
</ResponseField>

<ResponseField name="data.task_info" type="object" />

<ResponseField name="data.task_info.external_task_id" type="string" />

<ResponseField name="data.task_result" type="object" />

<ResponseField name="data.task_result.videos" type="object[]" />

<ResponseField name="data.task_result.videos[].duration" type="string">
  ビデオの合計再生時間（秒）
</ResponseField>

<ResponseField name="data.task_result.videos[].id" type="string">
  生成されたビデオのID
</ResponseField>

<ResponseField name="data.task_result.videos[].url" type="string (uri)">
  生成されたビデオのURL

  形式: `uri`
</ResponseField>

<ResponseField name="data.task_result.videos[].watermark_url" type="string (uri)">
  ウォーターマーク付きの生成されたビデオのURL、直リンク防止形式

  形式: `uri`
</ResponseField>

<ResponseField name="data.task_status" type="string">
  タスクステータス

  取り得る値: `submitted`、`processing`、`succeed`、`failed`
</ResponseField>

<ResponseField name="data.task_status_msg" type="string">
  タスクステータス情報。タスクが失敗した場合は失敗理由が表示されます
</ResponseField>

<ResponseField name="data.updated_at" type="integer">
  タスク更新時間、Unixタイムスタンプ（ミリ秒）
</ResponseField>

<ResponseField name="data.watermark_info" type="object" />

<ResponseField name="data.watermark_info.enabled" type="boolean" />

<ResponseField name="message" type="string">
  エラーメッセージ
</ResponseField>

<ResponseField name="request_id" type="string">
  リクエストID
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "aspect_ratio": "16:9",
  "duration": "5",
  "mode": "pro",
  "prompt": "A paper boat drifting down a rain-soaked street at dusk."
}
```

### 出力

```json theme={null}
{
  "code": 0,
  "data": {
    "created_at": 1798761600000,
    "task_id": "kling-task-1a2b3c4d5e6f",
    "task_result": {
      "videos": [
        {
          "duration": "5",
          "id": "kling-video-6f5e4d3c2b1a",
          "url": "https://example.invalid/kling/kling-v1/generated.mp4"
        }
      ]
    },
    "task_status": "succeed",
    "task_status_msg": "",
    "updated_at": 1798761840000
  },
  "message": "SUCCEED",
  "request_id": "9f2c1a04-7b6e-4d38-8a51-3c0e7d9b2f46"
}
```

## 出荷前の確認

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>
