Kling
创建一个 Kling 图生视频任务
通过 CometAPI POST /kling/v1/videos/image2video 将单张图片转换为 Kling 视频,支持异步任务创建和通过任务 ID 跟踪进度。
POST
/
kling
/
v1
/
videos
/
image2video
cURL
curl https://api.cometapi.com/kling/v1/videos/image2video \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://your-image-host/source.jpg",
"prompt": "A cinematic slow push-in on the subject",
"model_name": "kling-v3",
"mode": "pro",
"duration": "5",
"sound": "off"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/image2video",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image": "https://your-image-host/source.jpg",
"prompt": "A cinematic slow push-in on the subject",
"model_name": "kling-v3",
"mode": "pro",
"duration": "5",
"sound": "off"
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/image2video", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image": "https://your-image-host/source.jpg",
"prompt": "A cinematic slow push-in on the subject",
"model_name": "kling-v3",
"mode": "pro",
"duration": "5",
"sound": "off"
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/image2video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image' => 'https://your-image-host/source.jpg'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/image2video"
payload := strings.NewReader("{\n \"image\": \"https://your-image-host/source.jpg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/image2video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"https://your-image-host/source.jpg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/image2video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"image\": \"https://your-image-host/source.jpg\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"task_id": "2032273942220931072",
"task_status": "submitted",
"task_info": {},
"created_at": 1773366840306,
"updated_at": 1773366840306
}
}使用此端点将一张源图片制作成动画 Kling 视频。
调用前准备
- 提供一个公开图片 URL 或一个 base64 图片字符串
- 使用符合 Kling 像素要求的图片;过小的缩略图会被生成任务拒绝
- 先从默认的
kling-v2-6示例开始,然后在需要不同模型路线时,从 OpenAPI 枚举中选择另一个model_name - 首次请求尽量保持简单:一张输入图片、一个 prompt、无尾帧、无运动蒙版
- 当你需要可控的局部运动时,使用
dynamic_masks作为由蒙版和轨迹对象组成的数组 - 对于支持生成声音的模型路线,首次请求可使用
sound: off以获得确定性的无音频结果
模型命名
在此端点上使用常规的 Kling 视频 model ID。Omni model ID 请保留给 Omni Video。任务流程
1
提交图生视频请求
创建任务并保存返回的 Kling
task_id。2
轮询任务
继续使用 获取一个 Kling 任务 跟踪任务状态,直到输出就绪。
3
保存结果
如果你需要超出提供商交付 URL 保留期限的存储,请持久化保存已完成的资源。
完整参数参考请参见官方 Kling 文档。
请求体
application/json
最后修改于 2026年6月26日
⌘I
cURL
curl https://api.cometapi.com/kling/v1/videos/image2video \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://your-image-host/source.jpg",
"prompt": "A cinematic slow push-in on the subject",
"model_name": "kling-v3",
"mode": "pro",
"duration": "5",
"sound": "off"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/image2video",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image": "https://your-image-host/source.jpg",
"prompt": "A cinematic slow push-in on the subject",
"model_name": "kling-v3",
"mode": "pro",
"duration": "5",
"sound": "off"
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/image2video", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image": "https://your-image-host/source.jpg",
"prompt": "A cinematic slow push-in on the subject",
"model_name": "kling-v3",
"mode": "pro",
"duration": "5",
"sound": "off"
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/image2video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image' => 'https://your-image-host/source.jpg'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/image2video"
payload := strings.NewReader("{\n \"image\": \"https://your-image-host/source.jpg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/image2video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"https://your-image-host/source.jpg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/image2video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"image\": \"https://your-image-host/source.jpg\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"task_id": "2032273942220931072",
"task_status": "submitted",
"task_info": {},
"created_at": 1773366840306,
"updated_at": 1773366840306
}
}