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

# Kling 数字人 API

> kling-avatar：将任意人像照片转化为音频同步的口型对齐说话视频，并呈现自然表情。

## 概述

Kling Avatar 可将单张静态图片转化为与音频同步的说话视频。上传一张人像照片和一段音频文件，模型将根据音频中的语音节奏自动生成面部动作、口型同步及相应表情。

## 最佳效果使用建议

<Tip>
  请使用高质量的正面人像照片，确保面部特征清晰可见，避免极端角度或面部严重遮挡。源图像分辨率越高，人物还原度越好，生成瑕疵也越少。
</Tip>

## 查询任务状态

提交任务后，使用统一查询端点查看进度并获取结果：

<Card title="获取任务信息" icon="magnifying-glass" href="/zh/models/common/get-task-info">
  了解如何查询任务状态及获取生成结果
</Card>

<Tip>
  对于生产环境，我们建议在创建任务时使用 `callback_url` 参数，以便在生成完成时自动接收通知，而非持续轮询状态端点。
</Tip>

## 相关资源

<CardGroup cols={2}>
  <Card title="模型概览" icon="store" href="/zh/models/quickstart">
    探索所有可用模型
  </Card>

  <Card title="通用 API" icon="gear" href="/zh/common-api/get-account-credits">
    查询账户剩余积分
  </Card>
</CardGroup>


## OpenAPI

````yaml zh/models/kling/avatar.json post /api/v1/client/job/CreateTask
openapi: 3.0.0
info:
  title: Crun Kling Avatar API
  description: crun.ai Kling Avatar API 文档
  version: 1.0.0
  contact:
    name: 技术支持
    email: support@crun.ai
servers:
  - url: https://api.crun.ai
    description: API 服务器
security:
  - ApiKeyAuth: []
paths:
  /api/v1/client/job/CreateTask:
    post:
      summary: kling avatar 图像转视频生成
      operationId: kling/avatar
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  enum:
                    - kling/avatar
                  description: |-
                    用于生成的模型名称，必填字段。

                    - 使用本端点时必须填写 `kling/avatar`
                callback_url:
                  type: string
                  format: uri
                  description: |-
                    可选。用于接收任务完成通知的回调 URL。

                    - 生成完成后，系统将以 POST 方式向该 URL 推送任务状态与结果
                    - 回调数据结构与任务状态查询接口返回的 `data` 对象一致
                    - 您的回调端点需支持接收包含结果的 JSON 格式 POST 请求
                    - 成功接收后需返回 HTTP 200 状态码
                  example: https://your-domain.com/api/callback
                input:
                  type: object
                  description: Kling Avatar 图像转视频生成任务的输入参数
                  properties:
                    mode:
                      type: string
                      description: 标准模式分辨率为 720p，专业模式分辨率为 1080p。
                      enum:
                        - std
                        - pro
                      default: std
                      example: std
                    image_url:
                      type: string
                      description: >-
                        Avatar 参考图像。支持 .jpg/.jpeg/.png 格式，最大 10MB，尺寸不小于
                        300px，宽高比在 1:2.5 至 2.5:1 之间。
                      example: https://example.com/reference_avatar.png
                    audio_url:
                      type: string
                      description: >-
                        Avatar 音频文件。支持 .mp3/.wav/.m4a/.aac 格式，最大 5MB，时长须在 2 至
                        300 秒之间。
                      example: https://example.com/avatar_audio.mp3
                    prompt:
                      type: string
                      description: 正向文本提示词。可定义数字人动作、情绪及运镜等
                      example: 说话时兴奋地摇头，最后伸手握拳，下定决心出发，开心地跳跃
                      maxLength: 2500
                  required:
                    - image_url
                    - audio_url
            example:
              model: kling/avatar
              input:
                mode: pro
                image_url: https://example.com/reference_avatar.png
                audio_url: https://example.com/avatar_audio.mp3
                prompt: 说话时兴奋地摇头，最后伸手握拳，下定决心出发，开心地跳跃
      responses:
        '200':
          description: 请求成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          task_id:
                            type: string
                            description: 任务 ID，可通过获取任务详情接口查询任务状态
                            example: task_12345678
              example:
                code: 200
                message: success
                data:
                  task_id: task_12345678
        '422':
          description: 验证错误
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      errors:
                        type: array
                        description: 详细的验证错误信息
                        items:
                          type: string
                        example:
                          - specific error field message
              example:
                code: 422
                message: Missing Params or Type Error
                errors:
                  - specific error field message
        '500':
          $ref: '#/components/responses/Error'
components:
  schemas:
    ApiResponse:
      type: object
      properties:
        code:
          type: integer
          enum:
            - 200
            - 401
            - 402
            - 404
            - 422
            - 429
            - 455
            - 500
            - 501
            - 505
          description: |-
            响应状态码

            - **200**: 成功 - 请求已成功处理
            - **401**: 未授权 - 身份凭证缺失或无效
            - **402**: 额度不足 - 账户余额不足以完成本次操作
            - **404**: 未找到 - 请求的资源或端点不存在
            - **422**: 验证错误 - 请求参数未通过验证
            - **429**: 请求限速 - 该资源的请求次数已超出限制
            - **455**: 服务不可用 - 系统正在维护中
            - **500**: 服务器错误 - 处理请求时发生意外错误
            - **501**: 生成失败 - 内容生成任务失败
            - **505**: 功能已禁用 - 所请求的功能当前已被禁用
        message:
          type: string
          description: 响应消息，失败时为错误描述
          example: success
  responses:
    Error:
      description: 服务器错误
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: |-
        所有 API 均需通过 API Key 进行身份验证。

        获取 API Key：
        1. 访问 [API Key 管理页面](https://crun.ai/zh/user-api-key) 获取您的 API Key

        使用方式：
        将以下内容添加至请求头：

        x-api-key: YOUR_API_KEY

        注意事项：
        - 请妥善保管您的 API Key，切勿与他人共享
        - 若怀疑 API Key 已泄露，请立即在管理页面进行重置

````