数字人口播
本文档介绍如何在 aijisu 中使用 Kling Avatar v2 异步数字人视频生成接口。
当前支持模型:
| 模型名称 | 类型 | 适合场景 | 计费方式 |
|---|---|---|---|
kling-avatar-v2-standard | 数字人视频 | 常规口播、客服讲解、课程导语、营销短视频 | 按输出视频秒数计费 |
kling-avatar-v2-pro | 数字人视频 | 更高质量数字人口播、正式宣传片、品牌视频、重要课程内容 | 按输出视频秒数计费 |
接口采用异步任务模式:
| 操作 | 方法 | 路径 |
|---|---|---|
| 提交数字人视频任务 | POST | /v1/video/generations |
| 查询数字人视频任务 | GET | /v1/video/generations/{task_id} |
1. 通用鉴权
所有接口都需要在请求头中携带 API Key:
Authorization: Bearer sk-xxxxxxxxxxxxxxxx
Content-Type: application/json
示例域名:
https:
2. 模型简介
Kling Avatar v2 用于根据人物图片和音频生成数字人口播视频。用户需要提供一张人物图片和一段音频,模型会生成带口型和面部动作的视频。
支持两个版本:
| 模型 | 说明 |
|---|---|
kling-avatar-v2-standard | 标准版本,适合常规口播和批量生成 |
kling-avatar-v2-pro | Pro 版本,适合对画面、表情、稳定性要求更高的正式内容 |
3. 提交数字人视频任务
POST https://api.xxx.xx/v1/video/generations
3.1 请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | kling-avatar-v2-standard 或 kling-avatar-v2-pro |
image_url | string | 是 | 人物图片 URL |
audio_url | string | 是 | 音频 URL,用于驱动口型 |
audio_duration_seconds | number | 是 | 音频秒数,用于提交前预扣费估算 |
prompt | string | 否 | 风格提示,例如场景、人物状态、镜头感觉 |
注意:
audio_duration_seconds必须传。- 该字段用于提交前估价,避免无法预扣费。
- 请尽量传入音频真实秒数,避免费用预估和实际任务时长差异过大。
3.2 提交响应示例
{
"id": "task_xxxxxxxxxxxxx",
"task_id": "task_xxxxxxxxxxxxx",
"object": "video.generation.job",
"status": "queued"
}
字段说明:
| 字段 | 说明 |
|---|---|
id / task_id | 异步任务 ID,用于查询结果 |
status | 任务状态,常见值为 queued、processing、completed、failed |
4. 查询数字人视频任务
GET https://api.xxx.xx/v1/video/generations/{task_id}
查询示例:
curl -X GET "https://api.xxx.xx/v1/video/generations/task_xxxxxxxxxxxxx" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx"
完成响应示例:
{
"id": "task_xxxxxxxxxxxxx",
"task_id": "task_xxxxxxxxxxxxx",
"object": "video.generation.job",
"status": "completed",
"video_url": "https://api.xxx.xx/media/xxxxx.mp4",
"result": {
"outputs": [
"https://api.xxx.xx/media/xxxxx.mp4"
]
}
}
5. 请求示例
5.1 Standard 生成客服讲解视频
curl -X POST "https://api.xxx.xx/v1/video/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-avatar-v2-standard",
"image_url": "https://cdn.example.com/avatar/customer-service.png",
"audio_url": "https://cdn.example.com/audio/customer-intro.mp3",
"audio_duration_seconds": 12,
"prompt": "friendly customer service presenter, natural expression, clean studio lighting"
}'
5.2 Standard 生成课程导语
curl -X POST "https://api.xxx.xx/v1/video/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-avatar-v2-standard",
"image_url": "https://cdn.example.com/avatar/teacher.png",
"audio_url": "https://cdn.example.com/audio/course-opening.mp3",
"audio_duration_seconds": 18.5,
"prompt": "professional teacher, warm smile, stable camera, natural lip sync"
}'
5.3 Pro 生成品牌口播视频
curl -X POST "https://api.xxx.xx/v1/video/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-avatar-v2-pro",
"image_url": "https://cdn.example.com/avatar/brand-host.png",
"audio_url": "https://cdn.example.com/audio/brand-message.mp3",
"audio_duration_seconds": 24,
"prompt": "premium corporate spokesperson video, clean studio background, confident expression"
}'
5.4 Pro 生成新闻播报
curl -X POST "https://api.xxx.xx/v1/video/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-avatar-v2-pro",
"image_url": "https://cdn.example.com/avatar/news-anchor.png",
"audio_url": "https://cdn.example.com/audio/news-briefing.mp3",
"audio_duration_seconds": 32.7,
"prompt": "news anchor style, formal tone, stable frontal shot, neutral expression"
}'
6. 常见错误
6.1 缺少 image_url
数字人视频必须提供人物图片:
{
"image_url": "https://cdn.example.com/avatar.png"
}
6.2 缺少 audio_url
数字人视频必须提供驱动口型的音频:
{
"audio_url": "https://cdn.example.com/voice.mp3"
}
6.3 缺少 audio_duration_seconds
错误请求:
{
"model": "kling-avatar-v2-standard",
"image_url": "https://cdn.example.com/avatar.png",
"audio_url": "https://cdn.example.com/voice.mp3"
}
修复方式:补充音频秒数:
{
"audio_duration_seconds": 12.5
}
7. 推荐工作流
- 准备人物图片。
- 使用 TTS 或录音生成一段音频。
- 获取音频实际秒数。
- 提交
/v1/video/generations,传入image_url、audio_url、audio_duration_seconds。 - 轮询
/v1/video/generations/{task_id}。 - 任务完成后读取
video_url。
8. 最小可用请求
8.1 Avatar Standard
curl -X POST "https://api.xxx.xx/v1/video/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-avatar-v2-standard",
"image_url": "https://cdn.example.com/avatar.png",
"audio_url": "https://cdn.example.com/voice.mp3",
"audio_duration_seconds": 10
}'
8.2 Avatar Pro
curl -X POST "https://api.xxx.xx/v1/video/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-avatar-v2-pro",
"image_url": "https://cdn.example.com/avatar.png",
"audio_url": "https://cdn.example.com/voice.mp3",
"audio_duration_seconds": 10
}'