Kling 3.0 API 文档
将 Kling 3.0 和 Kling Video O3 API 集成到您应用程序的完整指南。
快速开始
| 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 | "type": "pro-text-to-video", |
| 6 | "prompt": "A cinematic shot of mountains at sunrise", |
| 7 | "duration": 5, |
| 8 | "aspect_ratio": "16:9" |
| 9 | }' |
身份认证
所有 API 请求都需要在 Authorization 头中使用 Bearer 令牌进行身份验证。
获取 API 密钥: 您可以在控制面板的 API Keys 页面获取您的 API 密钥。 → 获取 API 密钥
| 1 | Authorization: Bearer YOUR_API_KEY |
可用模型
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创建新的视频生成任务。API 会根据任务类型自动路由到正确的后端。
请求体
任务类型(如 pro-text-to-video, o3-pro-reference-to-video)
视频描述文本(最多 2000 字符)
视频时长(秒)。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 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检查视频生成任务的状态。根据 task_id 前缀路由(n75 为 Kling 3.0,n71 为 Kling O3)。
查询参数
生成接口返回的唯一任务 ID(如 n75xxx 为 Kling 3.0,n71xxx 为 O3)
请求示例
| 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 | 服务器错误,请稍后重试 |