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

# 为 Kling 唇形同步识别人脸

> 使用 Kling 唇形同步 API（POST /kling/v1/videos/identify-face）检测视频中的人脸，并驱动精确的唇形同步视频生成工作流。

在运行下游唇形同步工作流之前，使用此端点识别源视频中的人脸。

## 此路由返回什么

* 一个用于归组当前人脸检测结果的 `session_id`
* 一个包含一个或多个人脸的 `face_data` 数组
* 每张人脸的元数据，例如 `face_id`、预览图像和时间范围

## 何时使用它

* 精确传入一个来源：已完成的 Kling 视频使用 `video_id`，托管的 MP4 或 MOV 使用 `video_url`
* 在你为屏幕中有多人的视频构建唇形同步请求之前
* 当你需要选择特定人脸，而不是依赖自动选择时
* 当你想在启动成本更高的任务之前预览人脸覆盖范围时

<Tip>
  有关完整的参数参考，请参阅[官方 Kling 文档](https://kling.ai/document-api/apiReference/model/lipSync)。
</Tip>


## OpenAPI

````yaml api/openapi/video/kling/post-lip-sync.openapi.json POST /kling/v1/videos/identify-face
openapi: 3.1.0
info:
  title: Lip-Sync API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /kling/v1/videos/identify-face:
    post:
      summary: Lip-Sync
      operationId: lip_sync
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                video_id:
                  type: string
                  description: >-
                    Kling video id from a completed task. Send either video_id
                    or video_url.
                video_url:
                  type: string
                  description: Public MP4 or MOV URL. Send either video_id or video_url.
              default:
                video_url: https://your-video-host/source.mp4
              oneOf:
                - required:
                    - video_id
                - required:
                    - video_url
            examples:
              Default:
                summary: Identify faces from a video URL
                value:
                  video_url: https://your-video-host/source.mp4
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                  - request_id
                  - data
                properties:
                  code:
                    type: integer
                  message:
                    type: string
                  request_id:
                    type: string
                  data:
                    type: object
                    required:
                      - session_id
                      - face_data
                    properties:
                      session_id:
                        type: string
                      face_data:
                        type: array
                        items:
                          type: object
                          properties:
                            face_id:
                              type: string
                            face_image:
                              type: string
                            start_time:
                              type: integer
                            end_time:
                              type: integer
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/kling/v1/videos/identify-face \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "video_url": "https://your-video-host/source.mp4"
                }'
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/kling/v1/videos/identify-face",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                  "video_url": "https://your-video-host/source.mp4"
                },
            )

            result = response.json()
            print(result.get("code"), result.get("data", {}).get("session_id"))
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/kling/v1/videos/identify-face", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "video_url": "https://your-video-host/source.mp4"
              }),
            });


            const result = await response.json();

            console.log(result.code, result.data?.session_id);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````