多模态视觉语言 (MVL) 视频生成 -- 在单一接口中融合自然语言提示、视频/图片引用和主体参考,实现统一调用。
在所有请求中添加 Bearer Token 认证头:
Authorization: Bearer YOUR_API_KEY
| 模型 | API 名称 | 特性 | 价格 (8.5折) |
|---|---|---|---|
| Kling Video O1 | kling-video-o1 | 3-10s, MVL 多模态, 音频, 按秒计费 | 低至 $0.0064/秒 |
| Kling V3 Omni | kling-v3-omni | 3-15s, MVL 多模态, 音频, 保留原声, 按秒计费 | 低至 $0.0064/秒 |
| 模式 | 音频 | $/秒 |
|---|---|---|
| std | - | $0.0633 |
| std | on | $0.0956 |
| pro | - | $0.0853 |
| pro | on | $0.1280 |
| 模式 | 音频 | 保留原声 | $/秒 |
|---|---|---|---|
| std | - | - | $0.0633 |
| std | - | on | $0.0853 |
| std | on | - | $0.0956 |
| pro | - | - | $0.0853 |
| pro | - | on | $0.1059 |
| pro | on | - | $0.1280 |
/api/v1/video/generations创建可灵 Omni-Video 视频生成任务。底层使用统一的 omni-video 端点 (POST /kling/v1/videos/omni-video)。
/api/v1/video/generations?task_id=xxx查询任务状态并获取视频链接
curl -X POST https://apimodels.app/api/v1/video/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-video-o1",
"prompt": "A girl dancing on the beach at sunset, cinematic lighting",
"mode": "std",
"duration": "5",
"aspect_ratio": "16:9"
}'{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "pending",
"model": "kling-video/kling-video-o1"
}
}{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "completed",
"model": "kling-video/kling-video-o1",
"resultUrls": ["https://...video.mp4"],
"createTime": 1705123450000,
"completeTime": 1705123500000
}
}{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "failed",
"model": "kling-video/kling-video-o1",
"failMsg": "Content policy violation"
}
}在创建请求中传入 callback_url 后,任务进入 completed 或 failed 终态时,我们会向该地址发起一次 HTTP POST。请求头仅包含 Content-Type: application/json,无签名头。失败会自动重试 3 次(指数退避 1s/2s/4s,单次超时 10s);如果仍未成功,后台会在 30 分钟内继续补偿重发,直到接收端返回 2xx。
POST {your callback_url}
Content-Type: application/json
{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"model": "kling-video/kling-video-o1",
"state": "completed" | "failed",
"param": "<JSON string>", // request params, JSON.parse once
"resultJson": "<JSON string> | null", // result object, JSON.parse once
"failCode": null | "string",
"failMsg": null | "string",
"costTime": 12345, // duration in ms
"completeTime": 1705123500000, // ms epoch
"createTime": 1705123450000 // ms epoch
}
}注意:data.param 与 data.resultJson 都是 JSON 字符串,使用前必须 JSON.parse 一次。
{
"resultUrls": ["https://r2.apimodels.app/videos/xxx.mp4"],
"videoDuration": 5 // optional, seconds
}resultUrls 始终存在,长度通常为 1(失败时为空数组)。其它字段可选。state=failed 时 resultJson 通常为 null 或 {"resultUrls":[]}。
app.post('/webhook/kling-omni', express.json(), (req, res) => {
const { taskId, state, resultJson, failMsg } = req.body.data
if (state === 'completed') {
const r = JSON.parse(resultJson)
console.log('video ready', taskId, r.resultUrls[0], r.videoDuration)
} else {
console.warn('video failed', taskId, failMsg)
}
res.status(200).end() // must be 2xx, otherwise we retry
})pending任务已排队,等待处理processing视频生成中completed视频生成成功failed视频生成失败400请求错误 - 参数缺失或无效401未授权 - API 密钥无效402余额不足 - 积分不够404未找到 - 任务 ID 不存在500服务器内部错误