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

> Synthesize speech and animate a portrait with Kling Digital Human through AnyFast.

Kling Digital Human turns a portrait and a speech track into a talking-person video. The workflow uses two independent AnyFast endpoints: optional text-to-speech (TTS) at `POST /kling/v1/audio/tts`, followed by avatar generation at `POST /kling/v1/videos/avatar/image2video`.

<Info>
  TTS is a standalone synchronous API. Avatar generation is asynchronous. If you already have a supported audio file, skip TTS and pass the file with `sound_file`.
</Info>

## Workflow

<Steps>
  <Step title="Prepare speech">
    Call TTS to convert text into audio and read `data.task_result.audios[0].id`, or provide your own public audio URL.
  </Step>

  <Step title="Create the avatar task">
    Submit a portrait with either `audio_id` or `sound_file`. The two audio fields are mutually exclusive.
  </Step>

  <Step title="Poll by task ID">
    Read `task_id` from the creation response and poll `GET /kling/v1/videos/avatar/image2video/{task_id}` until `data.task_status` is `succeed` or `failed`.
  </Step>

  <Step title="Save the result">
    On success, download `data.task_result.videos[0].url`. Generated media can expire, so copy it to your own storage promptly.
  </Step>
</Steps>

## Supported inputs

| Capability       | Input                                                        | Important limits                                                                     |
| ---------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| TTS              | `text`, `voice_id`, `voice_language`, optional `voice_speed` | Text up to 1,000 characters; language `zh` or `en`; speed `0.8`–`2.0`                |
| Portrait         | Public URL or raw Base64 in `image`                          | JPG, JPEG, or PNG; up to 10 MB; each side at least 300 px; ratio from 1:2.5 to 2.5:1 |
| Generated speech | `audio_id` from TTS                                          | Created within 30 days; 2–300 seconds                                                |
| Existing speech  | Public URL or raw Base64 in `sound_file`                     | MP3, WAV, M4A, or AAC; up to 5 MB; 2–300 seconds                                     |
| Output quality   | `mode`                                                       | `std` or `pro`; default `std`                                                        |

When you send raw Base64, omit prefixes such as `data:image/png;base64,`.

## Create speech with TTS

```bash cURL theme={null}
curl --request POST \
  --url https://www.anyfast.ai/kling/v1/audio/tts \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "text": "Hello, welcome to the AnyFast digital human service.",
    "voice_id": "oversea_male1",
    "voice_language": "en",
    "voice_speed": 1.0
  }'
```

TTS returns the completed audio in the same response. Save both the reusable audio ID and the URL:

```text theme={null}
data.task_result.audios[0].id
data.task_result.audios[0].url
data.task_result.audios[0].duration
```

`voice_id` selects the TTS voice. Choose an ID from the [Kling AI Voice List](https://docs.qingque.cn/s/home/eZQDvafJ4vXQkP8T9ZPvmye8S?identityId=2E1MlYrrPk4) and set `voice_language` to the language shown for that voice. The returned audio `id` is an `audio_id`; these values are not interchangeable.

## Generate a digital human video

<Tabs sync={false}>
  <Tab title="Use a TTS audio ID">
    ```bash cURL theme={null}
    curl --request POST \
      --url https://www.anyfast.ai/kling/v1/videos/avatar/image2video \
      --header 'Authorization: Bearer YOUR_API_KEY' \
      --header 'Content-Type: application/json' \
      --data '{
        "image": "https://example.com/portrait.png",
        "audio_id": "AUDIO_ID_FROM_TTS",
        "prompt": "The person looks at the camera, speaks naturally, and nods gently.",
        "mode": "std",
        "watermark_info": {"enabled": true}
      }'
    ```
  </Tab>

  <Tab title="Use your own audio">
    ```bash cURL theme={null}
    curl --request POST \
      --url https://www.anyfast.ai/kling/v1/videos/avatar/image2video \
      --header 'Authorization: Bearer YOUR_API_KEY' \
      --header 'Content-Type: application/json' \
      --data '{
        "image": "https://example.com/portrait.png",
        "sound_file": "https://example.com/speech.mp3",
        "prompt": "The person looks at the camera and speaks with a friendly expression.",
        "mode": "pro",
        "watermark_info": {"enabled": false}
      }'
    ```
  </Tab>
</Tabs>

The creation response uses the AnyFast task wrapper. Read the task ID from either `task_id` or `id`.

## Query the task

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

The query response uses Kling task fields. Poll `data.task_status` through `submitted` and `processing`. These intermediate states can repeat or move between each other, so do not treat a state change as a failure. Stop only when the status becomes `succeed` or `failed`.

## Choose between `std` and `pro`

Use `std` for lower-cost previews and ordinary talking-head content. Use `pro` when output detail matters more. In live validation, both modes produced decodable videos with audio, and `pro` produced a higher-resolution result than `std`.

<Card title="Digital Human API Reference" icon="code" href="/api-reference/model-api/kuaishou/kling-digital-human">
  Review every supported request and response field for TTS and avatar generation.
</Card>

<script src="/public/feedback.js" />
