> ## 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 で Videos Lip Sync を使う

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

`kling/videos-lip-sync` の API リファレンスです。Kling から Comfy Router によって提供されます。

## クイックスタート

[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/videos-lip-sync`

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

<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/videos-lip-sync",
              {
                  "input": {
                      "mode": "text2video",
                      "text": "Welcome to Comfy Cloud.",
                      "video_id": "kling-video-6f5e4d3c2b1a",
                      "voice_id": "genshin_vindi2",
                      "voice_language": "en",
                      "voice_speed": 1,
                  },
              },
          )

      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/videos-lip-sync", {
        input: {
          mode: "text2video",
          text: "Welcome to Comfy Cloud.",
          video_id: "kling-video-6f5e4d3c2b1a",
          voice_id: "genshin_vindi2",
          voice_language: "en",
          voice_speed: 1,
        },
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/kling/videos-lip-sync \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"mode\":\"text2video\",\"text\":\"Welcome to Comfy Cloud.\",\"video_id\":\"kling-video-6f5e4d3c2b1a\",\"voice_id\":\"genshin_vindi2\",\"voice_language\":\"en\",\"voice_speed\":1}}"
      ```
    </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/videos-lip-sync",
              {
                  "input": {
                      "mode": "text2video",
                      "text": "Welcome to Comfy Cloud.",
                      "video_id": "kling-video-6f5e4d3c2b1a",
                      "voice_id": "genshin_vindi2",
                      "voice_language": "en",
                      "voice_speed": 1,
                  },
              },
          )
          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/videos-lip-sync", {
        input: {
          mode: "text2video",
          text: "Welcome to Comfy Cloud.",
          video_id: "kling-video-6f5e4d3c2b1a",
          voice_id: "genshin_vindi2",
          voice_language: "en",
          voice_speed: 1,
        },
      });
      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/videos-lip-sync/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"mode\":\"text2video\",\"text\":\"Welcome to Comfy Cloud.\",\"video_id\":\"kling-video-6f5e4d3c2b1a\",\"voice_id\":\"genshin_vindi2\",\"voice_language\":\"en\",\"voice_speed\":1}}"

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

## スキーマ

### 入力

<ParamField body="callback_url" type="string (uri)">
  コールバック通知アドレス。タスクのステータスが変更されるとサーバーから通知されます。

  形式: `uri`
</ParamField>

<ParamField body="input" type="object" required />

<ParamField body="input.audio_file" type="string">
  オーディオファイルのローカルパス。対応形式: .mp3/.wav/.m4a/.aac、最大ファイルサイズ 5MB。Base64コード。
</ParamField>

<ParamField body="input.audio_type" type="string">
  リップシンク用のオーディオファイルの送信方法。mode が audio2video の場合に必須です。

  指定可能な値: `file`、`url`
</ParamField>

<ParamField body="input.audio_url" type="string">
  オーディオファイルのダウンロードURL。対応形式: .mp3/.wav/.m4a/.aac、最大ファイルサイズ 5MB。
</ParamField>

<ParamField body="input.mode" type="string" required>
  ビデオ生成モード。text2video: テキストから動画への生成モード、audio2video: オーディオから動画への生成モード

  指定可能な値: `text2video`、`audio2video`
</ParamField>

<ParamField body="input.text" type="string">
  リップシンクビデオ生成用のテキストコンテンツ。mode が text2video の場合に必須です。最大長は 120 文字です。
</ParamField>

<ParamField body="input.video_id" type="string">
  Kling AI によって生成されたビデオの ID。過去 30 日以内に生成された 5 秒または 10 秒のビデオのみサポートします。
</ParamField>

<ParamField body="input.video_url" type="string">
  アップロードされたビデオのリンクを取得します。ビデオファイルは .mp4/.mov に対応し、ファイルサイズは 100MB を超えず、ビデオの長さは 2～10 秒です。
</ParamField>

<ParamField body="input.voice_id" type="string">
  ボイス ID。mode が text2video の場合に必須です。システムは選択可能なさまざまなボイスオプションを提供しています。
</ParamField>

<ParamField body="input.voice_language" type="string" default="&#x22;en&#x22;">
  ボイス言語はボイス ID に対応します。

  指定可能な値: `zh`、`en`
</ParamField>

<ParamField body="input.voice_speed" type="number" default="1">
  話速。有効範囲: 0.8～2.0、小数点第 1 位まで正確です。

  範囲: `0.8` から `2`
</ParamField>

Router が `GET /v2/models/kling/videos-lip-sync/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.updated_at" type="integer">
  タスク更新時間、Unix タイムスタンプ（ミリ秒）
</ResponseField>

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

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

## 例

### 入力

```json theme={null}
{
  "input": {
    "mode": "text2video",
    "text": "Welcome to Comfy Cloud.",
    "video_id": "kling-video-6f5e4d3c2b1a",
    "voice_id": "genshin_vindi2",
    "voice_language": "en",
    "voice_speed": 1
  }
}
```

### 出力

```json theme={null}
{
  "code": 0,
  "data": {
    "created_at": 1798761600000,
    "task_id": "kling-lip-sync-task-4f3e2d1c0b9a",
    "task_result": {
      "videos": [
        {
          "duration": "8",
          "id": "kling-video-9a8b7c6d5e4f",
          "url": "https://example.invalid/kling/videos-lip-sync/generated.mp4"
        }
      ]
    },
    "task_status": "succeed",
    "updated_at": 1798761780000
  },
  "message": "SUCCEED",
  "request_id": "5e0a9b17-6d3c-42f8-91b4-7a2c8d6e0f35"
}
```

## 出荷前の確認

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>
