Skip to content

🎬 视频模型 可灵 kling

  • 2024.09.10 本站已经支持 视频模型 kling-video 绘图模型 kling-image
  • kling 接入官网的API,
  • 支持 文生图 图生图 文生视频 图生视频
  • 计费是按次数,一次一个视频
  • 如何使用 访问 https://kling.ddaiai.com 看下面的 在线测试

在线测试

1.访问 https://kling.ddaiai.com (如果被墙了,换下二级域名前缀 suibian)
2.如果发现被墙了 可以自己换地址 https://suibian.ddaiai.comsuibian 换其他的 如 https://20245.ddaiai.com 都能访问

设置

kling

效果

kling

计费

  • 图片按张
  • 视频影响价格的有 时长10s为2倍价格,模式pro为3.5倍价格

API调用

  • 约定 header中含有 Authorization : Bearer hk-你的key

1.绘图生成

post https://api.openai-hk.com/kling/v1/images/generations

shell
curl --request POST \
  --url https://api.openai-hk.com/kling/v1/images/generations \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'content-type: application/json' \
  --data '{
  "prompt": "漫画兔子吃草",
  "negative_prompt":''
  ,"image":''
  ,"image_fidelity":0.5
  ,"n":1
  ,"aspect_ratio":"4:3"
  ,"notify_hook":""
}'
curl --request POST \
  --url https://api.openai-hk.com/kling/v1/images/generations \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'content-type: application/json' \
  --data '{
  "prompt": "漫画兔子吃草",
  "negative_prompt":''
  ,"image":''
  ,"image_fidelity":0.5
  ,"n":1
  ,"aspect_ratio":"4:3"
  ,"notify_hook":""
}'

参数说明

参数类型说明
promptstring正向文本提示,必须,不能超过500个字符
negative_promptstring负向文本提示,可选,不能超过200个字符
imagestring参考图片,可选,支持Base64编码或图片URL,支持.jpg / .jpeg / .png格式,大小不能超过10MB
image_fidelitynumber生成过程中对用户上传图片的参考强度,可选,取值范围:[0,1]
nnumber生成图片数量,可选,取值范围:[1,9]
aspect_ratiostring生成图片的纵横比,可选,枚举值:16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3
notify_hookstring通知回调地址,可选,不填则不通知

返回体

json
{
	"code": 0,
	"message": "成功",
	"request_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
	"data": {
		"task_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
		"task_status": "submitted",
		"created_at": 1725974776706,
		"updated_at": 1725974776706
	}
}
{
	"code": 0,
	"message": "成功",
	"request_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
	"data": {
		"task_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
		"task_status": "submitted",
		"created_at": 1725974776706,
		"updated_at": 1725974776706
	}
}

返回得到的 data.task_id 用于查询结果

2.文生视频

post https://api.openai-hk.com/kling/v1/videos/text2video

shell
curl --request POST \
  --url https://api.openai-hk.com/kling/v1/videos/text2video \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'content-type: application/json' \
  --data '{
  "prompt": "太空飞船在航行" 
}'
curl --request POST \
  --url https://api.openai-hk.com/kling/v1/videos/text2video \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'content-type: application/json' \
  --data '{
  "prompt": "太空飞船在航行" 
}'

请求体 全格式

json
{
  "prompt": "太空飞船在航行" ,
  "negative_prompt": "" ,
  "cfg_scale": 0 ,
  "mode": "std" ,
  "aspect_ratio": "1:1" ,
  "duration": "5" , 
  "camera_control": {
    "type": "simple",
    "config": {
      "horizontal":1, //只能其中一个 而且不能为0
    //   "vertical": 1,
    //   "pan": 1,
    //   "tilt": -1,
    //   "roll": 1,
    //   "zoom": -1
    }
  }
  ,"notify_hook":""
}
{
  "prompt": "太空飞船在航行" ,
  "negative_prompt": "" ,
  "cfg_scale": 0 ,
  "mode": "std" ,
  "aspect_ratio": "1:1" ,
  "duration": "5" , 
  "camera_control": {
    "type": "simple",
    "config": {
      "horizontal":1, //只能其中一个 而且不能为0
    //   "vertical": 1,
    //   "pan": 1,
    //   "tilt": -1,
    //   "roll": 1,
    //   "zoom": -1
    }
  }
  ,"notify_hook":""
}

说明

参数类型说明
promptstring正向文本提示,必须,不能超过500个字符
negative_promptstring负向文本提示,可选,不能超过200个字符
cfg_scalenumber生成过程中对用户上传图片的参考强度,可选,取值范围:[0,1]
modestring生成模式,可选,枚举值:std高性能, pro高表现
aspect_ratiostring生成图片的纵横比,可选,枚举值:16:9, 9:16, 1:1
durationstring生成视频时长,可选,单位为秒
camera_controlObject控制摄像机运动的协议,可选,未指定则智能匹配;
截止20240809:仅5s&高性能std的情况下支持镜头控制,其他情况不支持
camera_control.typestring可选,枚举值 simple down_back forward_up right_turn_forward left_turn_forward 具体说明在下面
camera_control.configObject包含六个字段,用于指定摄像机的运动或变化
camera_control.config.horizontalint水平运镜,可选,取值范围:[-10, 10]
camera_control.config.verticalint垂直运镜,可选,取值范围:[-10, 10]
camera_control.config.panint水平摇镜,可选,取值范围:[-10, 10]
camera_control.config.tiltint垂直摇镜,可选,取值范围:[-10, 10]
camera_control.config.rollint旋转运镜,可选,取值范围:[-10, 10]
camera_control.config.zoomint变焦,可选,取值范围:[-10, 10]
notify_hookstring通知回调地址,可选,不填则不通知

camera_control.type 参数说明

参数说明
simple简单运镜,此类型下可在"config"中六选一进行运镜
down_back镜头下压并后退 ➡️ 下移拉远,此类型下config参数无需填写
forward_up镜头前进并上仰 ➡️ 推进上移,此类型下config参数无需填写
right_turn_forward先右旋转后前进 ➡️ 右旋推进,此类型下config参数无需填写
left_turn_forward先左旋并前进 ➡️ 左旋推进,此类型下config参数无需填写

返回体

json
{
	"code": 0,
	"message": "成功",
	"request_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
	"data": {
		"task_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
		"task_status": "submitted",
		"created_at": 1725974776706,
		"updated_at": 1725974776706
	}
}
{
	"code": 0,
	"message": "成功",
	"request_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
	"data": {
		"task_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
		"task_status": "submitted",
		"created_at": 1725974776706,
		"updated_at": 1725974776706
	}
}

返回得到的 data.task_id 用于查询结果

3.图生视频

post https://api.openai-hk.com/kling/v1/videos/image2video

shell
curl --request POST \
  --url https://api.openai-hk.com/kling/v1/videos/image2video \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'content-type: application/json' \
  --data '{
  "image": "https://pics2.baidu.com/feed/fc1f4134970a304e8662f052c91a3188c8175c32.jpeg" 
}'
curl --request POST \
  --url https://api.openai-hk.com/kling/v1/videos/image2video \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'content-type: application/json' \
  --data '{
  "image": "https://pics2.baidu.com/feed/fc1f4134970a304e8662f052c91a3188c8175c32.jpeg" 
}'

请求体 全格式

json
{
  "image": "https://pics2.baidu.com/feed/fc1f4134970a304e8662f052c91a3188c8175c32.jpeg" , 
  "image_tail": "" , 
  "prompt": "" ,
  "negative_prompt": "" ,
  "cfg_scale": 0 ,
  "mode": "std" ,
  "aspect_ratio": "1:1" ,
  "duration": "5" 
   ,"notify_hook":""
  
}
{
  "image": "https://pics2.baidu.com/feed/fc1f4134970a304e8662f052c91a3188c8175c32.jpeg" , 
  "image_tail": "" , 
  "prompt": "" ,
  "negative_prompt": "" ,
  "cfg_scale": 0 ,
  "mode": "std" ,
  "aspect_ratio": "1:1" ,
  "duration": "5" 
   ,"notify_hook":""
  
}

说明

参数类型说明
imagestring参考图像,必须,支持Base64编码或图片URL,支持.jpg / .jpeg / .png格式,大小不能超过10MB,分辨率不小于300*300px
image_tailstring参考图像 - 尾帧控制,可选,支持Base64编码或图片URL,支持.jpg / .jpeg / .png格式,大小不能超过10MB,分辨率不小于300*300px
promptstring正向文本提示,可选,不能超过500个字符
negative_promptstring负向文本提示,可选,不能超过200个字符
cfg_scalenumber生成过程中对用户上传图片的参考强度,可选,取值范围:[0,1]
modestring生成模式,可选,枚举值:std高性能, pro高表现
aspect_ratiostring生成图片的纵横比,可选,枚举值:16:9, 9:16, 1:1
durationstring生成视频时长,可选,单位为秒
notify_hookstring通知回调地址,可选,不填则不通知

返回体

json
{
	"code": 0,
	"message": "成功",
	"request_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
	"data": {
		"task_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
		"task_status": "submitted",
		"created_at": 1725974776706,
		"updated_at": 1725974776706
	}
}
{
	"code": 0,
	"message": "成功",
	"request_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
	"data": {
		"task_id": "Cl6Mq2bftxoAAAAAAA_SxQ",
		"task_status": "submitted",
		"created_at": 1725974776706,
		"updated_at": 1725974776706
	}
}

返回得到的 data.task_id 用于查询结果

4.获取任务

get https://api.openai-hk.com/kling/v1/{act1}/{act2}/{task_id}

参数必须说明
act1images (文生图) 或videos
act2generations(文生图)、text2videoimage2video
task_id返回得到的 data.task_id

返回体

  • 图片
json
{
	"code": 0,
	"message": "成功",
	"request_id": "Clo_MGbfunoAAAAAABB5XA",
	"data": {
		"task_id": "Clo_MGbfunoAAAAAABB5XA",
		"task_status": "succeed",
		"task_status_msg": "",
		"created_at": 1725977118293,
		"updated_at": 1725977125849,
		"task_result": {
			"images": [
				{
					"index": 0,
					"url": "https://cdn.klingai.com/bs2/upload-kling-api/9575341070/image/Clo_MGbfunoAAAAAABB5XA-0_raw_image_0.png"
				}
			],
			"videos": null
		}
	}
}
{
	"code": 0,
	"message": "成功",
	"request_id": "Clo_MGbfunoAAAAAABB5XA",
	"data": {
		"task_id": "Clo_MGbfunoAAAAAABB5XA",
		"task_status": "succeed",
		"task_status_msg": "",
		"created_at": 1725977118293,
		"updated_at": 1725977125849,
		"task_result": {
			"images": [
				{
					"index": 0,
					"url": "https://cdn.klingai.com/bs2/upload-kling-api/9575341070/image/Clo_MGbfunoAAAAAABB5XA-0_raw_image_0.png"
				}
			],
			"videos": null
		}
	}
}
  • 视频
json
{
	"code": 0,
	"message": "成功",
	"request_id": "CmZ4r2bfunIAAAAAABDEJw",
	"data": {
		"task_id": "CmZ4r2bfunIAAAAAABDEJw",
		"task_status": "succeed",
		"task_status_msg": "",
		"created_at": 1725977783786,
		"updated_at": 1725978074639,
		"task_result": {
			"images": null,
			"videos": [
				{
					"id": "cb6a5273-e12b-4731-98e7-c6fd45302027",
					"url": "https://cdn.klingai.com/bs2/upload-kling-api/9575341070/text2video/CmZ4r2bfunIAAAAAABDEJw-0_raw_video_1.mp4",
					"duration": "5.1"
				}
			]
		}
	}
}
{
	"code": 0,
	"message": "成功",
	"request_id": "CmZ4r2bfunIAAAAAABDEJw",
	"data": {
		"task_id": "CmZ4r2bfunIAAAAAABDEJw",
		"task_status": "succeed",
		"task_status_msg": "",
		"created_at": 1725977783786,
		"updated_at": 1725978074639,
		"task_result": {
			"images": null,
			"videos": [
				{
					"id": "cb6a5273-e12b-4731-98e7-c6fd45302027",
					"url": "https://cdn.klingai.com/bs2/upload-kling-api/9575341070/text2video/CmZ4r2bfunIAAAAAABDEJw-0_raw_video_1.mp4",
					"duration": "5.1"
				}
			]
		}
	}
}