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

# Kling Lip Sync

> Identify a face, create a Kling lip-sync task, and query the generated video.

Use the **Face Recognition** tab first to obtain `session_id` and `face_id`, then submit them in the **Lip Sync** tab. The audio input is either `face_choose[].audio_id` or `face_choose[].sound_file`. To start from text, first call [Kling Digital Human TTS](https://docs.anyfast.ai/api-reference/model-api/kling/kling-digital-human.md) and use the returned audio `id`.

> [tab] Lip Sync
>
> ## Create task
>
> `POST /kling/v1/videos/advanced-lip-sync`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url https://www.anyfast.ai/kling/v1/videos/advanced-lip-sync \
>   --header 'Authorization: Bearer YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "session_id": "923976763809071143",
>     "face_choose": [
>       {
>         "face_id": "0",
>         "sound_file": "https://example.com/speech.mp3",
>         "sound_start_time": 0,
>         "sound_end_time": 3000,
>         "sound_insert_time": 1000,
>         "sound_volume": 1.0,
>         "original_audio_volume": 1.0
>       }
>     ],
>     "watermark_info": {"enabled": false}
>   }'
> ```
>
> ## Request headers
>
> **Authorization** `string` *required*
>
> Bearer authentication in the form `Bearer YOUR_API_KEY`.
>
> **Content-Type** `string` *required* (default: application/json)
>
> Data exchange format.
>
> ## Request body
>
> **session\_id** `string` *required*
>
> Session ID returned by Identify Face.
>
> **face\_choose** `object[]` *required*
>
> Face and driving-audio configuration. Provide exactly one item.
>
> **face\_choose\[].face\_id** `string` *required*
>
> Face ID returned in `data.face_data[].face_id` by Identify Face.
>
> **face\_choose\[].audio\_id** `string`
>
> Audio ID created within the last 30 days. The selected audio must be 2–60 seconds. Provide exactly one of `audio_id` and `sound_file`.
>
> **face\_choose\[].sound\_file** `string`
>
> Public audio URL or raw Base64. MP3, WAV, and M4A are supported through AnyFast; maximum size 5 MB and duration 2–60 seconds. Provide exactly one of `sound_file` and `audio_id`.
>
> **face\_choose\[].sound\_start\_time** `integer` *required*
>
> Crop start in the source audio, in milliseconds.
>
> **face\_choose\[].sound\_end\_time** `integer` *required*
>
> Crop end in the source audio, in milliseconds. It must not exceed the source audio duration.
>
> **face\_choose\[].sound\_insert\_time** `integer` *required*
>
> Insertion point in the video, in milliseconds. The inserted segment must remain inside the video and overlap the selected face by at least 2 seconds.
>
> **face\_choose\[].sound\_volume** `number` (default: 1)
>
> Inserted-audio volume from `0` through `2`.
>
> **face\_choose\[].original\_audio\_volume** `number` (default: 1)
>
> Original-video volume from `0` through `2`.
>
> **watermark\_info** `object`
>
> Watermark configuration.
>
> **watermark\_info.enabled** `boolean`
>
> Whether to generate a watermarked result.
>
> **callback\_url** `string`
>
> Public callback URL for task-status notifications.
>
> ## Create response
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "request_id": "",
>   "data": {
>     "task_id": "asyntask_AhmnzEDa847dDNcIR4sQ385evWXR44V7",
>     "task_status": "submitted",
>     "created_at": 1788321762398,
>     "updated_at": 1788321762398
>   }
> }
> ```
>
> **code** `integer`
>
> Business result code. `0` indicates acceptance.
>
> **message** `string`
>
> Business message. It can be empty on success.
>
> **request\_id** `string`
>
> Request ID field. It can be empty.
>
> **data.task\_id** `string`
>
> AnyFast task ID used to query the result.
>
> **data.task\_status** `string`
>
> Initial task status. An accepted task returns `submitted`.
>
> **data.created\_at** `integer`
>
> Creation time as a Unix timestamp in milliseconds.
>
> **data.updated\_at** `integer`
>
> Update time as a Unix timestamp in milliseconds.
>
> ## Query task
>
> `GET /kling/v1/videos/advanced-lip-sync/{task_id}`
>
> ```bash cURL theme={null}
> curl --request GET \
>   --url https://www.anyfast.ai/kling/v1/videos/advanced-lip-sync/asyntask_AhmnzEDa847dDNcIR4sQ385evWXR44V7 \
>   --header 'Authorization: Bearer YOUR_API_KEY'
> ```
>
> ## Request headers and path
>
> **Authorization** `string` *required*
>
> Bearer authentication in the form `Bearer YOUR_API_KEY`.
>
> **task\_id** `string` *required*
>
> AnyFast task ID returned by task creation.
>
> ## Response
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "data": {
>     "task_id": "asyntask_AhmnzEDa847dDNcIR4sQ385evWXR44V7",
>     "task_status": "succeed",
>     "task_result": {
>       "videos": [
>         {
>           "url": "https://example.com/lip-sync-result.mp4",
>           "duration": "12"
>         }
>       ]
>     },
>     "created_at": 1788321762000,
>     "updated_at": 1788322364000
>   }
> }
> ```
>
> **code** `integer`
>
> Business result code. `0` indicates success.
>
> **message** `string`
>
> Business message. It can be empty on success.
>
> **data.task\_id** `string`
>
> AnyFast task ID.
>
> **data.task\_status** `string`
>
> Task status: `submitted`, `processing`, `succeed`, or `failed`.
>
> **data.task\_status\_msg** `string`
>
> Failure details when the task fails.
>
> **data.task\_result.videos** `object[]`
>
> Generated video results. Present when the task succeeds.
>
> **data.task\_result.videos\[].url** `string`
>
> Generated video URL.
>
> **data.task\_result.videos\[].duration** `string`
>
> Reported video duration in seconds.
>
> **data.created\_at** `integer`
>
> Creation time as a Unix timestamp in milliseconds.
>
> **data.updated\_at** `integer`
>
> Update time as a Unix timestamp in milliseconds.

> [tab] Face Recognition
>
> ## Identify faces
>
> `POST /kling/v1/videos/identify-face`
>
> ```bash cURL theme={null}
> curl --request POST \
>   --url https://www.anyfast.ai/kling/v1/videos/identify-face \
>   --header 'Authorization: Bearer YOUR_API_KEY' \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "video_url": "https://example.com/person-speaking.mp4"
>   }'
> ```
>
> ## Request headers
>
> **Authorization** `string` *required*
>
> Bearer authentication in the form `Bearer YOUR_API_KEY`.
>
> **Content-Type** `string` *required* (default: application/json)
>
> Data exchange format.
>
> ## Request body
>
> **video\_url** `string`
>
> Public MP4 or MOV URL. The video must be 2–60 seconds, no larger than 100 MB, and use 720p or 1080p resolution with each edge from 512 through 2,160 px. Provide exactly one of `video_url` and `video_id`.
>
> **video\_id** `string`
>
> ID of a Kling-generated video created within the last 30 days. Provide exactly one of `video_id` and `video_url`.
>
> ## Response
>
> ```json 200 theme={null}
> {
>   "code": "0",
>   "message": "SUCCEED",
>   "requestId": "request_01J8K7H4T7FQ6V6K6A",
>   "data": {
>     "session_id": "926174688823869522",
>     "face_data": [
>       {
>         "face_id": "0",
>         "face_image": "https://example.com/detected-face.png",
>         "start_time": 0,
>         "end_time": 12000
>       }
>     ],
>     "final_unit_deduction": "0.05",
>     "final_balance_deduction": {
>       "quota": "0",
>       "list_price": "0"
>     }
>   }
> }
> ```
>
> **code** `string`
>
> Business result code. `0` indicates success.
>
> **message** `string`
>
> Business result message.
>
> **requestId** `string`
>
> Request identifier returned by the current AnyFast endpoint.
>
> **data.session\_id** `string`
>
> Session ID required by the lip-sync request.
>
> **data.face\_data** `object[]`
>
> Detected faces and their usable time intervals.
>
> **data.face\_data\[].face\_id** `string`
>
> Face ID to pass in `face_choose[].face_id`.
>
> **data.face\_data\[].face\_image** `string`
>
> Preview image for the detected face.
>
> **data.face\_data\[].start\_time** `integer`
>
> Usable interval start in milliseconds.
>
> **data.face\_data\[].end\_time** `integer`
>
> Usable interval end in milliseconds.
>
> **data.final\_unit\_deduction** `string`
>
> Final Kling unit deduction.
>
> **data.final\_balance\_deduction** `object`
>
> Balance-deduction details returned by the provider.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.