Kling API 文档
用一个 API Key 把 Kling 4.0、Kling 4.0 Flash、Kling 3.0 和 Kling Video O3 接入你的应用,完整集成指南。
快速开始
| 1 | curl -X POST 'https://kling3api.com/api/generate' \ |
| 2 | -H 'Authorization: Bearer YOUR_API_KEY' \ |
| 3 | -H 'Content-Type: application/json' \ |
| 4 | -d '{ |
| 5 | "model": "kling-4.0", |
| 6 | "prompt": "A cinematic shot of mountains at sunrise", |
| 7 | "duration": 5, |
| 8 | "resolution": "1080p", |
| 9 | "aspect_ratio": "16:9" |
| 10 | }' |
身份认证
所有 API 请求都需要在 Authorization 头中使用 Bearer 令牌进行身份验证。
获取 API 密钥: 您可以在控制面板的 API Keys 页面获取您的 API 密钥。 → 获取 API 密钥
| 1 | Authorization: Bearer YOUR_API_KEY |
可用模型
Kling 4.0 新
3–30 秒、720p 或 1080p,支持参考图、主体、声音和关键帧
选择方式 "model": "kling-4.0"
| 类型 | 描述 | 时长 | 积分 |
|---|---|---|---|
reference-to-video | 文本、参考图、主体和声音(自动选择) | 3-30s | 28.5/s (720p) · 42.5/s (1080p) |
keyframe-to-video | 首帧、中间帧和尾帧(自动选择) | 3-30s | 28.5/s (720p) · 42.5/s (1080p) |
Kling 4.0 Flash 新
更低成本的 720p 短片,支持图生视频、参考素材和视频编辑
选择方式 "model": "kling-4.0-flash"
| 类型 | 描述 | 时长 | 积分 |
|---|---|---|---|
text-to-video | 文生视频,720p | 3-20s | 24/s |
image-to-video | 让首帧图片动起来,提示词可选 | 3-20s | 24/s |
reference-to-video | 最多 10 张图片和 5 个参考视频 | 3-20s | 24/s · 32/s (videos) |
video-edit | 用提示词编辑源视频,按源视频秒数计费 | auto (3-20s) | 32/s |
Kling 3.0
高质量 4K 视频生成
| 类型 | 描述 | 时长 | 积分 |
|---|---|---|---|
pro-text-to-video | Pro 品质文生视频 | 3-15s | 54/s (no audio) · 80/s (with audio) |
pro-image-to-video | Pro 品质图生视频 | 3-15s | 54/s (no audio) · 80/s (with audio) |
std-text-to-video | 标准品质文生视频 | 3-15s | 40/s (no audio) · 60/s (with audio) |
std-image-to-video | 标准品质图生视频 | 3-15s | 40/s (no audio) · 60/s (with audio) |
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 端点
/api/generate创建视频生成任务。Kling 4 系列把 model 设为 kling-4.0 或 kling-4.0-flash;Kling 3.0 和 O3 由 type 字段选择后端。
请求体
Kling 4 系列模型:kling-4.0 或 kling-4.0-flash。不传时使用 type 字段调用 Kling 3.0 或 O3。每个 Kling 4 模型有自己的字段,详见模型指南。
Kling 3.0 / O3 任务类型(如 pro-text-to-video、o3-pro-reference-to-video)。设置了 model 时不需要。
要生成的视频的文字描述。长度上限:Kling 3.0 为 2,000 字符,Kling 4.0 为 8,000,Kling 4.0 Flash 为 2,500。
视频时长(秒)。Kling 3.0: 3-15。O3: 3-15。 Defaults to 5.
输出宽高比(16:9, 9:16, 1:1) Defaults to 16:9.
图生视频任务的图片 URL
结束帧图片 URL(仅限图生视频)
参考视频或视频编辑任务的视频 URL
参考图片 URL 数组(O3 参考生成,最多 7 张)
启用原生音频生成 Defaults to true.
负面提示词,避免生成某些元素
提示词遵循度(0-1,仅限 Kling 3.0) Defaults to 0.5.
Kling 4.0 - 参考图
| 1 | { |
| 2 | "model": "kling-4.0", |
| 3 | "prompt": "The woman from @image_1 walks into the cafe from @image_2 and orders a coffee", |
| 4 | "image_urls": [ |
| 5 | "https://example.com/woman.jpg", |
| 6 | "https://example.com/cafe.png" |
| 7 | ], |
| 8 | "duration": 8, |
| 9 | "resolution": "1080p", |
| 10 | "aspect_ratio": "9:16" |
| 11 | } |
Kling 4.0 - 关键帧
| 1 | { |
| 2 | "model": "kling-4.0", |
| 3 | "prompt": "Start on @first_frame and settle on @last_frame in one continuous move", |
| 4 | "first_frame_url": "https://example.com/start.jpg", |
| 5 | "last_frame_url": "https://example.com/end.jpg", |
| 6 | "duration": 6, |
| 7 | "resolution": "720p" |
| 8 | } |
Kling 4.0 Flash - 图生视频
| 1 | { |
| 2 | "model": "kling-4.0-flash", |
| 3 | "prompt": "The product slowly rotates while soft light sweeps across it", |
| 4 | "image": "https://example.com/product.jpg", |
| 5 | "duration": 5 |
| 6 | } |
Kling 4.0 Flash - 视频编辑
| 1 | { |
| 2 | "model": "kling-4.0-flash", |
| 3 | "mode": "video-edit", |
| 4 | "prompt": "Turn the daytime street into a snowy night", |
| 5 | "video": "https://example.com/street.mp4", |
| 6 | "keep_original_sound": true |
| 7 | } |
Kling 3.0 - 文生视频
| 1 | { |
| 2 | "type": "pro-text-to-video", |
| 3 | "prompt": "A majestic eagle soaring through clouds at sunset", |
| 4 | "duration": 5, |
| 5 | "aspect_ratio": "16:9", |
| 6 | "sound": true |
| 7 | } |
Kling 3.0 - 图生视频
| 1 | { |
| 2 | "type": "pro-image-to-video", |
| 3 | "prompt": "The character slowly turns and smiles", |
| 4 | "image": "https://example.com/my-image.jpg", |
| 5 | "duration": 5 |
| 6 | } |
Kling O3 - 参考生成
| 1 | { |
| 2 | "type": "o3-pro-reference-to-video", |
| 3 | "prompt": "The character walks through a futuristic city", |
| 4 | "images": [ |
| 5 | "https://example.com/character-reference.jpg", |
| 6 | "https://example.com/style-reference.jpg" |
| 7 | ], |
| 8 | "duration": 5, |
| 9 | "aspect_ratio": "16:9" |
| 10 | } |
Kling O3 - 视频编辑
| 1 | { |
| 2 | "type": "o3-pro-video-edit", |
| 3 | "prompt": "Change the background to a snowy mountain landscape", |
| 4 | "video": "https://example.com/original-video.mp4", |
| 5 | "keep_original_sound": true |
| 6 | } |
响应
Task created successfully
| 1 | { |
| 2 | "code": 200, |
| 3 | "message": "success", |
| 4 | "data": { |
| 5 | "task_id": "n75abc123kling3", |
| 6 | "status": "IN_PROGRESS", |
| 7 | "consumed_credits": 400 |
| 8 | } |
| 9 | } |
/api/status查询视频生成任务状态。任何模型都传 /api/generate 返回的 task_id,API 会自动转到对应后端。
查询参数
生成接口返回的任务 ID,适用于所有模型
请求示例
| 1 | curl -X GET 'https://kling3api.com/api/status?task_id=n75abc123kling3' \ |
| 2 | -H 'Authorization: Bearer YOUR_API_KEY' |
💡 Tip: 状态 API 中的 response 字段是一个视频 URL 数组,您可以直接通过 data.response[0] 获取视频 URL。
| 1 | // Extract video URL from response |
| 2 | const videoUrl = data.response[0]; |
响应
| 1 | { |
| 2 | "code": 200, |
| 3 | "message": "success", |
| 4 | "data": { |
| 5 | "task_id": "n75abc123kling3", |
| 6 | "status": "SUCCESS", |
| 7 | "consumed_credits": 400, |
| 8 | "created_at": "2026-02-05T10:30:00Z", |
| 9 | "request": { |
| 10 | "type": "pro-text-to-video", |
| 11 | "prompt": "A majestic eagle soaring through clouds at sunset", |
| 12 | "duration": 5, |
| 13 | "aspect_ratio": "16:9" |
| 14 | }, |
| 15 | "response": [ |
| 16 | "https://cdn.example.com/videos/abc123.mp4" |
| 17 | ], |
| 18 | "error_message": null, |
| 19 | "type": "pro-text-to-video" |
| 20 | } |
| 21 | } |
API 测试工具
直接在浏览器中测试 API。将 YOUR_API_KEY 替换为您的实际 API 密钥。
错误代码
| 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 | 服务器错误,请稍后重试 |