Appearance
🎬 视频模型 可灵 kling
- 2024.09.10 本站已经支持 视频模型
kling-video
绘图模型kling-image
kling
接入官网的API,- 支持
文生图
图生图
文生视频
图生视频
- 计费是按次数,一次一个视频
- 如何使用 访问 https://kling.ddaiai.com 看下面的
在线测试
在线测试
1.访问 https://kling.ddaiai.com (如果被墙了,换下二级域名前缀 suibian
)
2.如果发现被墙了 可以自己换地址 https://suibian.ddaiai.com
把 suibian
换其他的 如 https://20245.ddaiai.com
都能访问
设置
- 打开 https://kling.ddaiai.com
- 下图相应的地方设置
- 可灵 接口地址:https://api.openai-hk.com
- 可灵 KEY: hk-你的apiKey
效果
计费
- 图片按张
- 视频影响价格的有 时长
10s
为2倍价格,模式pro
为3.5倍价格
API调用
- 约定 header中含有
Authorization : Bearer hk-你的key
1.绘图生成
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":""
}'
参数说明
参数 | 类型 | 说明 |
---|---|---|
prompt | string | 正向文本提示,必须,不能超过500个字符 |
negative_prompt | string | 负向文本提示,可选,不能超过200个字符 |
image | string | 参考图片,可选,支持Base64编码或图片URL,支持.jpg / .jpeg / .png格式,大小不能超过10MB |
image_fidelity | number | 生成过程中对用户上传图片的参考强度,可选,取值范围:[0,1] |
n | number | 生成图片数量,可选,取值范围:[1,9] |
aspect_ratio | string | 生成图片的纵横比,可选,枚举值:16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3 |
notify_hook | string | 通知回调地址,可选,不填则不通知 |
返回体
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.文生视频
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": 0,
"vertical": 0,
"pan": 0,
"tilt": 0,
"roll": 0,
"zoom": 0
}
}
,"notify_hook":""
}
{
"prompt": "太空飞船在航行" ,
"negative_prompt": "" ,
"cfg_scale": 0 ,
"mode": "std" ,
"aspect_ratio": "1:1" ,
"duration": "5" ,
"camera_control": {
"type": "simple",
"config": {
"horizontal": 0,
"vertical": 0,
"pan": 0,
"tilt": 0,
"roll": 0,
"zoom": 0
}
}
,"notify_hook":""
}
说明
参数 | 类型 | 说明 |
---|---|---|
prompt | string | 正向文本提示,必须,不能超过500个字符 |
negative_prompt | string | 负向文本提示,可选,不能超过200个字符 |
cfg_scale | number | 生成过程中对用户上传图片的参考强度,可选,取值范围:[0,1] |
mode | string | 生成模式,可选,枚举值:std 高性能, pro 高表现 |
aspect_ratio | string | 生成图片的纵横比,可选,枚举值:16:9, 9:16, 1:1 |
duration | string | 生成视频时长,可选,单位为秒 |
camera_control | Object | 控制摄像机运动的协议,可选,未指定则智能匹配; 截止20240809:仅5s&高性能std的情况下支持镜头控制,其他情况不支持 |
camera_control.type | string | 可选,枚举值 simple down_back forward_up right_turn_forward left_turn_forward 具体说明在下面 |
camera_control.config | Object | 包含六个字段,用于指定摄像机的运动或变化 |
camera_control.config.horizontal | int | 水平运镜,可选,取值范围:[-10, 10] |
camera_control.config.vertical | int | 垂直运镜,可选,取值范围:[-10, 10] |
camera_control.config.pan | int | 水平摇镜,可选,取值范围:[-10, 10] |
camera_control.config.tilt | int | 垂直摇镜,可选,取值范围:[-10, 10] |
camera_control.config.roll | int | 旋转运镜,可选,取值范围:[-10, 10] |
camera_control.config.zoom | int | 变焦,可选,取值范围:[-10, 10] |
notify_hook | string | 通知回调地址,可选,不填则不通知 |
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.图生视频
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":""
}
说明
参数 | 类型 | 说明 |
---|---|---|
image | string | 参考图像,必须,支持Base64编码或图片URL,支持.jpg / .jpeg / .png格式,大小不能超过10MB,分辨率不小于300*300px |
image_tail | string | 参考图像 - 尾帧控制,可选,支持Base64编码或图片URL,支持.jpg / .jpeg / .png格式,大小不能超过10MB,分辨率不小于300*300px |
prompt | string | 正向文本提示,可选,不能超过500个字符 |
negative_prompt | string | 负向文本提示,可选,不能超过200个字符 |
cfg_scale | number | 生成过程中对用户上传图片的参考强度,可选,取值范围:[0,1] |
mode | string | 生成模式,可选,枚举值:std 高性能, pro 高表现 |
aspect_ratio | string | 生成图片的纵横比,可选,枚举值:16:9, 9:16, 1:1 |
duration | string | 生成视频时长,可选,单位为秒 |
notify_hook | string | 通知回调地址,可选,不填则不通知 |
返回体
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}
参数 | 必须 | 说明 |
---|---|---|
act1 | 是 | images (文生图) 或videos |
act2 | 是 | generations (文生图)、text2video 、image2video |
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"
}
]
}
}
}