跳转到主要内容
POST
/
kling
/
v1
/
videos
/
avatar
/
image2video
Create a Kling avatar task
curl --request POST \
  --url https://api.cometapi.com/kling/v1/videos/avatar/image2video \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "image": "example"
}
'
{
  "code": 123,
  "message": "<string>",
  "data": {
    "task_id": "<string>",
    "task_status": "<string>",
    "created_at": 123,
    "updated_at": 123,
    "task_info": {}
  }
}
使用此端点可通过一张源图像加一个音频源创建会说话的数字人片段。

调用前准备

  • 提供一个数字人 image,可以是公开 URL 或原始 base64 字符串
  • 仅发送 audio_idsound_file 其中之一
  • 首次请求请尽量保持简单:一张人脸图片、一个音频片段,以及一个可选的简短 prompt
  • 除非你明确需要更高质量的路径,否则请先使用 mode: std

音频源规则

  • 如果你已经通过 Kling TTS 路径生成了语音,audio_id 是最简单的方式
  • 如果你已经有自己的 MP3、WAV、M4A 或 AAC 资源,则可以使用 sound_file
  • 文档中说明数字人音频时长为 2 到 60 秒

任务流程

1

创建数字人任务

提交图像和一个音频源,然后保存返回的任务 id。
2

轮询任务

继续使用单独查询,直到任务进入终态。
3

保存完成结果

如果你需要在提供方交付 URL 失效后继续保留结果,请将最终资源复制到你自己的存储中。
完整参数参考请参见官方 Kling Avatar 文档

授权

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

请求头

Content-Type
string

Optional content type header.

请求体

application/json
image
string
默认值:example
必填

Avatar reference image. Accepts an image URL or raw Base64 string (no data: prefix). Supported formats: JPG, JPEG, PNG. Max file size 10 MB. Minimum dimension 300 px on each side; aspect ratio between 1:2.5 and 2.5:1.

audio_id
string
必填

Audio ID returned by the Kling TTS API. Only audio clips between 2 and 60 seconds generated within the last 30 days are accepted. Mutually exclusive with sound_file — exactly one must be provided.

sound_file
string

Audio file as a URL or Base64 string. Accepted formats: MP3, WAV, M4A, AAC. Max 5 MB, duration 2–60 seconds. Mutually exclusive with audio_id — exactly one must be provided.

prompt
string

Text prompt to guide avatar actions, emotions, and camera movements. Max 2500 characters.

mode
string

Generation mode. std (standard, faster and more cost-effective) or pro (professional, higher quality output).

callback_url
string

Webhook URL for task status notifications. The server sends a callback when the task status changes.

external_task_id
string

Optional user-defined task ID for your own tracking. Does not replace the system-generated task ID. Must be unique per account.

响应

200 - application/json

Task accepted.

code
integer
必填
message
string
必填
data
object
必填