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

> Detect a face, attach speech, and generate a lip-synced video with Kling's native workflow.

Kling Lip Sync re-animates one detected face in a source video to match a speech track. AnyFast exposes the native Kling workflow: first identify the face, then submit `session_id` and `face_choose` at the root of the lip-sync request.

> [!NOTE]
>
> The lip-sync audio input is either `face_choose[].audio_id` or `face_choose[].sound_file`. To start from text, first call the [Kling Digital Human TTS endpoint](https://docs.anyfast.ai/guides/model-api/kling/kling-digital-human.md), then pass the returned audio `id` as `face_choose[].audio_id`.

## Workflows

> [tab] Existing audio
>
> ```text theme={null}
> Identify Face
>   → session_id + face_id
>   → Kling Lip Sync with sound_file
>   → task_id
>   → Query task
>   → result video URL
> ```

> [tab] Text to speech
>
> ```text theme={null}
> Identify Face
>   → session_id + face_id
> TTS
>   → audio_id
> Kling Lip Sync with audio_id
>   → task_id
>   → Query task
>   → result video URL
> ```

`voice_id` selects a TTS voice. `audio_id` identifies the audio generated by TTS. Do not pass a `voice_id` where the lip-sync endpoint expects an `audio_id`.

## Prerequisite: identify the face

Call `POST /kling/v1/videos/identify-face` with either `video_url` or `video_id`. Save:

```text theme={null}
data.session_id
data.face_data[0].face_id
```

The source video must be 2–60 seconds, MP4 or MOV, 720p or 1080p, no more than 100 MB, and between 512 px and 2,160 px on each side. The complete request is documented in the **Face Recognition** tab of the [Kling Lip Sync API Reference](https://docs.anyfast.ai/api-reference/model-api/kling/kling-lip-sync.md).

## Create a lip-sync task

> [tab] Use an audio file
>
> ```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": "SESSION_ID_FROM_IDENTIFY_FACE",
>     "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}
>   }'
> ```

> [tab] Use a TTS audio ID
>
> ```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": "SESSION_ID_FROM_IDENTIFY_FACE",
>     "face_choose": [
>       {
>         "face_id": "0",
>         "audio_id": "AUDIO_ID_FROM_TTS",
>         "sound_start_time": 0,
>         "sound_end_time": 3000,
>         "sound_insert_time": 0,
>         "sound_volume": 1.0,
>         "original_audio_volume": 1.0
>       }
>     ],
>     "watermark_info": {"enabled": true}
>   }'
> ```

The endpoint currently supports one `face_choose` item. Provide exactly one of `audio_id` and `sound_file`.

## Timing and volume

| Field | Meaning | Limits |
| - | - | - |
| `sound_start_time` | Start of the crop in the source audio | Milliseconds from the beginning of the audio |
| `sound_end_time` | End of the crop in the source audio | Must not exceed the source audio duration |
| `sound_insert_time` | Placement of the cropped audio in the video | The inserted segment must remain inside the video and overlap the chosen face by at least 2 seconds |
| `sound_volume` | Inserted-speech volume | `0`–`2`, default `1` |
| `original_audio_volume` | Original-video volume | `0`–`2`, default `1`; no effect if the source video has no audio |

The cropped audio must be 2–60 seconds. For `sound_file`, use a public URL or raw Base64. MP3, WAV, and M4A have been validated through AnyFast; keep files within 5 MB.

## Query the result

```bash cURL theme={null}
curl --request GET \
  --url https://www.anyfast.ai/kling/v1/videos/advanced-lip-sync/TASK_ID \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

Poll `data.task_status` through `submitted` and `processing`. Stop on `succeed` or `failed`. A successful response returns the result at `data.task_result.videos[0].url` and its reported duration at `data.task_result.videos[0].duration`.

> [card] [Kling Lip Sync API Reference](https://docs.anyfast.ai/api-reference/model-api/kling/kling-lip-sync.md)
>
> Review request, response, timing, and query fields.


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