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

<Tabs sync={false}>
  <Tab title="Avatar">
    ## Create task

    `POST /kling/v1/videos/avatar/image2video`

    <div className="kling-api-example-panel">
      ```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}
        }'
      ```
    </div>

    ## Request headers

    <ParamField header="Authorization" type="string" required>Bearer authentication in the form `Bearer YOUR_API_KEY`.</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>Data exchange format.</ParamField>

    ## Request body

    <ParamField body="image" type="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.</ParamField>
    <ParamField body="audio_id" type="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`.</ParamField>
    <ParamField body="sound_file" type="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`.</ParamField>
    <ParamField body="prompt" type="string">Optional motion, emotion, and camera direction. Maximum length: 2,500 characters.</ParamField>
    <ParamField body="mode" type="string" default="std">Generation mode: `std` or `pro`.</ParamField>
    <ParamField body="watermark_info" type="object">Watermark configuration.</ParamField>
    <ParamField body="watermark_info.enabled" type="boolean">Whether to generate a watermarked result.</ParamField>
    <ParamField body="callback_url" type="string">Public callback URL for task-status notifications.</ParamField>

    ## Create response

    <div className="kling-api-example-panel">
      ```json 200 theme={null}
      {
        "id": "asyntask_6prd3xHk76S1sTivIgGjQzrA4ziDrRCX",
        "task_id": "asyntask_6prd3xHk76S1sTivIgGjQzrA4ziDrRCX",
        "object": "video",
        "model": "kling-v1",
        "status": "queued",
        "progress": 0,
        "created_at": 1790319846
      }
      ```
    </div>

    <ResponseField name="id" type="string">AnyFast task ID.</ResponseField>
    <ResponseField name="task_id" type="string">AnyFast task ID, identical to `id`.</ResponseField>
    <ResponseField name="object" type="string">Returned object type. For this endpoint, `video`.</ResponseField>
    <ResponseField name="model" type="string">Underlying request model identifier returned by the endpoint.</ResponseField>
    <ResponseField name="status" type="string">Initial AnyFast status. An accepted task returns `queued`.</ResponseField>
    <ResponseField name="progress" type="integer">Initial progress percentage.</ResponseField>
    <ResponseField name="created_at" type="integer">Creation time as a Unix timestamp in seconds.</ResponseField>

    ## Query task

    `GET /kling/v1/videos/avatar/image2video/{task_id}`

    <div className="kling-api-example-panel">
      ```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'
      ```
    </div>

    ## Request headers and path

    <ParamField header="Authorization" type="string" required>Bearer authentication in the form `Bearer YOUR_API_KEY`.</ParamField>
    <ParamField path="task_id" type="string" required>AnyFast task ID returned by avatar creation.</ParamField>

    ## Response

    <div className="kling-api-example-panel">
      ```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
        }
      }
      ```
    </div>

    <ResponseField name="code" type="integer">Business result code. `0` indicates success.</ResponseField>
    <ResponseField name="message" type="string">Business message. It can be empty on success.</ResponseField>
    <ResponseField name="data.task_id" type="string">AnyFast task ID.</ResponseField>
    <ResponseField name="data.task_status" type="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.</ResponseField>
    <ResponseField name="data.task_status_msg" type="string">Failure details when the task fails.</ResponseField>
    <ResponseField name="data.task_result.videos" type="object[]">Generated video results. Present when the task succeeds.</ResponseField>
    <ResponseField name="data.task_result.videos[].url" type="string">Generated video URL.</ResponseField>
    <ResponseField name="data.task_result.videos[].duration" type="string">Reported video duration in seconds.</ResponseField>
    <ResponseField name="data.created_at" type="integer">Creation time as a Unix timestamp in milliseconds.</ResponseField>
    <ResponseField name="data.updated_at" type="integer">Update time as a Unix timestamp in milliseconds.</ResponseField>
  </Tab>

  <Tab title="TTS">
    ## Generate speech

    `POST /kling/v1/audio/tts`

    <div className="kling-api-example-panel">
      ```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
        }'
      ```
    </div>

    ## Request headers

    <ParamField header="Authorization" type="string" required>Bearer authentication in the form `Bearer YOUR_API_KEY`.</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>Data exchange format.</ParamField>

    ## Request body

    <ParamField body="text" type="string" required>Text to synthesize. Maximum length: 1,000 characters.</ParamField>
    <ParamField body="voice_id" type="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`.</ParamField>
    <ParamField body="voice_language" type="string" default="zh" required>Voice language. Supported values: `zh`, `en`.</ParamField>
    <ParamField body="voice_speed" type="number" default={1.0}>Speech speed from `0.8` through `2.0`, rounded to one decimal place.</ParamField>

    ## Response

    <div className="kling-api-example-panel">
      ```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"
          }
        }
      }
      ```
    </div>

    <ResponseField name="code" type="integer">Business result code. `0` indicates success.</ResponseField>
    <ResponseField name="message" type="string">Business result message.</ResponseField>
    <ResponseField name="request_id" type="string">Request identifier for troubleshooting.</ResponseField>
    <ResponseField name="data.task_id" type="string">TTS task identifier.</ResponseField>
    <ResponseField name="data.task_status" type="string">TTS status. A successful synchronous request returns `succeed`.</ResponseField>
    <ResponseField name="data.task_result.audios" type="object[]">Generated audio results.</ResponseField>
    <ResponseField name="data.task_result.audios[].id" type="string">Audio ID accepted by avatar and lip-sync APIs.</ResponseField>
    <ResponseField name="data.task_result.audios[].url" type="string">Generated audio URL.</ResponseField>
    <ResponseField name="data.task_result.audios[].duration" type="string">Audio duration in seconds.</ResponseField>
    <ResponseField name="data.final_unit_deduction" type="string">Final Kling unit deduction.</ResponseField>
    <ResponseField name="data.final_balance_deduction" type="object">Balance-deduction details returned by the provider.</ResponseField>
    <ResponseField name="data.created_at" type="integer">Creation time as a Unix timestamp in milliseconds.</ResponseField>
    <ResponseField name="data.updated_at" type="integer">Update time as a Unix timestamp in milliseconds.</ResponseField>
  </Tab>
</Tabs>

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