> ## 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, create a Kling Digital Human video, and query the result.

Use TTS when you need to create speech from text, then pass its `audio_id` to avatar generation. If you already have an audio file, pass it with `sound_file` and skip TTS.

> [tab] Avatar
>
> ## Create task
>
> `POST /kling/v1/videos/avatar/image2video`
>
> ```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": "932365483050274872",
>     "prompt": "The person looks at the camera, speaks naturally, and nods gently.",
>     "mode": "std",
>     "watermark_info": {"enabled": true}
>   }'
> ```
>
> ## 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
>
> **image** `string` *required*
>
> Public image URL or raw Base64. Supports JPG, JPEG, and PNG up to 10 MB. Each side must be at least 300 px and the aspect ratio must be between 1:2.5 and 2.5:1. Do not add a data-URI prefix to Base64.
>
> **audio\_id** `string`
>
> Audio ID produced within the last 30 days. The audio must be 2–300 seconds. Provide exactly one of `audio_id` and `sound_file`.
>
> **sound\_file** `string`
>
> Public audio URL or raw Base64. Supports MP3, WAV, M4A, and AAC up to 5 MB and 2–300 seconds. Provide exactly one of `sound_file` and `audio_id`.
>
> **prompt** `string`
>
> Optional motion, emotion, and camera direction. Maximum length: 2,500 characters.
>
> **mode** `string` (default: std)
>
> Generation mode: `std` or `pro`.
>
> **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}
> {
>   "id": "asyntask_6prd3xHk76S1sTivIgGjQzrA4ziDrRCX",
>   "task_id": "asyntask_6prd3xHk76S1sTivIgGjQzrA4ziDrRCX",
>   "object": "video",
>   "model": "kling-v1",
>   "status": "queued",
>   "progress": 0,
>   "created_at": 1790319846
> }
> ```
>
> **id** `string`
>
> AnyFast task ID.
>
> **task\_id** `string`
>
> AnyFast task ID, identical to `id`.
>
> **object** `string`
>
> Returned object type. For this endpoint, `video`.
>
> **model** `string`
>
> Underlying request model identifier returned by the endpoint.
>
> **status** `string`
>
> Initial AnyFast status. An accepted task returns `queued`.
>
> **progress** `integer`
>
> Initial progress percentage.
>
> **created\_at** `integer`
>
> Creation time as a Unix timestamp in seconds.
>
> ## Query task
>
> `GET /kling/v1/videos/avatar/image2video/{task_id}`
>
> ```bash cURL theme={null}
> curl --request GET \
>   --url https://www.anyfast.ai/kling/v1/videos/avatar/image2video/asyntask_6prd3xHk76S1sTivIgGjQzrA4ziDrRCX \
>   --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 avatar creation.
>
> ## Response
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "",
>   "data": {
>     "task_id": "asyntask_6prd3xHk76S1sTivIgGjQzrA4ziDrRCX",
>     "task_status": "succeed",
>     "task_result": {
>       "videos": [
>         {
>           "url": "https://example.com/digital-human.mp4",
>           "duration": "5"
>         }
>       ]
>     },
>     "created_at": 1790319846000,
>     "updated_at": 1790320090000
>   }
> }
> ```
>
> **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`. Intermediate states can repeat or move between `submitted` and `processing`; treat only `succeed` and `failed` as terminal.
>
> **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] TTS
>
> ## Generate speech
>
> `POST /kling/v1/audio/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
>   }'
> ```
>
> ## 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
>
> **text** `string` *required*
>
> Text to synthesize. Maximum length: 1,000 characters.
>
> **voice\_id** `string` *required*
>
> Voice ID from the [Kling AI Voice List](https://docs.qingque.cn/s/home/eZQDvafJ4vXQkP8T9ZPvmye8S?identityId=2E1MlYrrPk4). Its listed language must match `voice_language`.
>
> **voice\_language** `string` *required* (default: zh)
>
> Voice language. Supported values: `zh`, `en`.
>
> **voice\_speed** `number` (default: 1)
>
> Speech speed from `0.8` through `2.0`, rounded to one decimal place.
>
> ## Response
>
> ```json 200 theme={null}
> {
>   "code": 0,
>   "message": "SUCCEED",
>   "request_id": "request_01J8K7E7H4T7FQ6V6K6A",
>   "data": {
>     "task_id": "tts_task_01J8K7E7H4",
>     "task_status": "succeed",
>     "task_result": {
>       "audios": [
>         {
>           "id": "932365483050274872",
>           "url": "https://example.com/generated-speech.mp3",
>           "duration": "4.067"
>         }
>       ]
>     },
>     "created_at": 1790321772436,
>     "updated_at": 1790321774387,
>     "final_unit_deduction": "0.05",
>     "final_balance_deduction": {
>       "quota": "0",
>       "list_price": "0"
>     }
>   }
> }
> ```
>
> **code** `integer`
>
> Business result code. `0` indicates success.
>
> **message** `string`
>
> Business result message.
>
> **request\_id** `string`
>
> Request identifier for troubleshooting.
>
> **data.task\_id** `string`
>
> TTS task identifier.
>
> **data.task\_status** `string`
>
> TTS status. A successful synchronous request returns `succeed`.
>
> **data.task\_result.audios** `object[]`
>
> Generated audio results.
>
> **data.task\_result.audios\[].id** `string`
>
> Audio ID accepted by avatar and lip-sync APIs.
>
> **data.task\_result.audios\[].url** `string`
>
> Generated audio URL.
>
> **data.task\_result.audios\[].duration** `string`
>
> Audio duration in seconds.
>
> **data.final\_unit\_deduction** `string`
>
> Final Kling unit deduction.
>
> **data.final\_balance\_deduction** `object`
>
> Balance-deduction details returned by the provider.
>
> **data.created\_at** `integer`
>
> Creation time as a Unix timestamp in milliseconds.
>
> **data.updated\_at** `integer`
>
> Update time as a Unix timestamp in milliseconds.


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