Kling 3.0 API 文档
将 Kling 3.0 和 Kling Video O3 API 集成到您应用程序的完整指南。
API v1.0 Base URL: https://kling3api.com
快速开始
bash
curl -X POST 'https://kling3api.com/api/generate' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"type": "pro-text-to-video",
"prompt": "A cinematic shot of mountains at sunrise",
"duration": 5,
"aspect_ratio": "16:9"
}'身份认证
所有 API 请求都需要在 Authorization 头中使用 Bearer 令牌进行身份验证。
获取 API 密钥: 您可以在控制面板的 API Keys 页面获取您的 API 密钥。
http
Authorization: Bearer YOUR_API_KEY可用模型
3.0
Kling 3.0
高质量 4K 视频生成
| 类型 | 描述 | 时长 | 积分 |
|---|---|---|---|
pro-text-to-video | Pro 品质文生视频 | 5s / 10s | 240 / 480 |
pro-image-to-video | Pro 品质图生视频 | 5s / 10s | 240 / 480 |
std-text-to-video | 标准品质文生视频 | 5s / 10s | 180 / 360 |
std-image-to-video | 标准品质图生视频 | 5s / 10s | 180 / 360 |
O3
Kling Video O3
支持参考图/视频编辑的新一代模型
| 类型 | 描述 | 时长 | 积分 |
|---|---|---|---|
o3-pro-text-to-video | O3 Pro 文生视频 | 3-15s | 48/s |
o3-pro-image-to-video | O3 Pro 图生视频 | 3-15s | 48/s |
o3-pro-reference-to-video | O3 Pro 参考图/视频生成 | 3-15s | 72/s |
o3-pro-video-edit | O3 Pro 视频编辑 | auto | 435 fixed |
o3-std-text-to-video | O3 标准 文生视频 | 3-15s | 36/s |
o3-std-image-to-video | O3 标准 图生视频 | 3-15s | 36/s |
o3-std-reference-to-video | O3 标准 参考生成 | 3-15s | 20/s |
o3-std-video-edit | O3 标准 视频编辑 | auto | 360 fixed |
API 端点
POST
/api/generate创建新的视频生成任务。API 会根据任务类型自动路由到正确的后端。
请求体
| Parameter | 类型 | 必填 | 描述 |
|---|---|---|---|
type | string | 必填 | 任务类型(如 pro-text-to-video, o3-pro-reference-to-video) |
prompt | string | 必填 | 视频描述文本(最多 2000 字符) |
duration | number | 可选 | 视频时长(秒)。Kling 3.0: 5 或 10。O3: 3-15。 (默认值: 5) |
aspect_ratio | string | 可选 | 输出宽高比(16:9, 9:16, 1:1) (默认值: 16:9) |
image | string | 可选 | 图生视频任务的图片 URL |
end_image | string | 可选 | 结束帧图片 URL(仅限图生视频) |
video | string | 可选 | 参考视频或视频编辑任务的视频 URL |
images | string[] | 可选 | 参考图片 URL 数组(O3 参考生成,最多 7 张) |
sound | boolean | 可选 | 启用原生音频生成 (默认值: false) |
negative_prompt | string | 可选 | 负面提示词,避免生成某些元素 |
cfg_scale | number | 可选 | 提示词遵循度(0-1,仅限 Kling 3.0) (默认值: 0.5) |
Kling 3.0 - 文生视频
json
{
"type": "pro-text-to-video",
"prompt": "A majestic eagle soaring through clouds at sunset",
"duration": 5,
"aspect_ratio": "16:9",
"sound": true
}Kling 3.0 - 图生视频
json
{
"type": "pro-image-to-video",
"prompt": "The character slowly turns and smiles",
"image": "https://example.com/my-image.jpg",
"duration": 5
}Kling O3 - 参考生成
json
{
"type": "o3-pro-reference-to-video",
"prompt": "The character walks through a futuristic city",
"images": [
"https://example.com/character-reference.jpg",
"https://example.com/style-reference.jpg"
],
"duration": 5,
"aspect_ratio": "16:9"
}Kling O3 - 视频编辑
json
{
"type": "o3-pro-video-edit",
"prompt": "Change the background to a snowy mountain landscape",
"video": "https://example.com/original-video.mp4",
"keep_original_sound": true
}响应
Task created successfully
{
"code": 200,
"message": "success",
"data": {
"task_id": "n70abc123kling3",
"status": "IN_PROGRESS",
"consumed_credits": 240
}
}GET
/api/statusAPI 测试工具
直接在浏览器中测试 API。将 YOUR_API_KEY 替换为您的实际 API 密钥。
API 测试沙盒POST
错误代码
| Status | Code | Description |
|---|---|---|
| 400 错误请求 | INVALID_PROMPT | 提示词无效或为空 |
| 400 错误请求 | INVALID_DURATION | 时长超出支持范围 |
| 400 错误请求 | INVALID_TYPE | 不支持的任务类型 |
| 400 错误请求 | MISSING_IMAGE | 图生视频任务需要提供图片 |
| 400 错误请求 | MISSING_VIDEO | 视频编辑任务需要提供视频 |
| 401 未授权 | INVALID_API_KEY | API 密钥缺失或无效 |
| 402 | INSUFFICIENT_CREDITS | 积分不足 |
| 429 请求过多 | RATE_LIMITED | 请求过于频繁,请稍后再试 |
| 500 服务器内部错误 | INTERNAL_ERROR | 服务器错误,请稍后重试 |