Kling
创建一个 Kling 多图视频任务
通过 CometAPI POST /kling/v1/videos/multi-image2video 从多张图片创建 Kling 视频,并可为生成设置运动控制和输出参数。
POST
/
kling
/
v1
/
videos
/
multi-image2video
cURL
curl https://api.cometapi.com/kling/v1/videos/multi-image2video \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image_list": [
{
"image": "https://your-image-host/first-frame.jpg"
},
{
"image": "https://your-image-host/second-frame.jpg"
}
],
"prompt": "A smooth transition between the two reference moments",
"mode": "std",
"duration": "5",
"aspect_ratio": "1:1"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/multi-image2video",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image_list": [
{
"image": "https://your-image-host/first-frame.jpg"
},
{
"image": "https://your-image-host/second-frame.jpg"
}
],
"prompt": "A smooth transition between the two reference moments",
"mode": "std",
"duration": "5",
"aspect_ratio": "1:1"
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/multi-image2video", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image_list": [
{
"image": "https://your-image-host/first-frame.jpg"
},
{
"image": "https://your-image-host/second-frame.jpg"
}
],
"prompt": "A smooth transition between the two reference moments",
"mode": "std",
"duration": "5",
"aspect_ratio": "1:1"
}),
});
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/multi-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_list' => [
[
'image' => 'https://your-image-host/first-frame.jpg'
],
[
'image' => 'https://your-image-host/second-frame.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/multi-image2video"
payload := strings.NewReader("{\n \"image_list\": [\n {\n \"image\": \"https://your-image-host/first-frame.jpg\"\n },\n {\n \"image\": \"https://your-image-host/second-frame.jpg\"\n }\n ]\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/multi-image2video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image_list\": [\n {\n \"image\": \"https://your-image-host/first-frame.jpg\"\n },\n {\n \"image\": \"https://your-image-host/second-frame.jpg\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/multi-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_list\": [\n {\n \"image\": \"https://your-image-host/first-frame.jpg\"\n },\n {\n \"image\": \"https://your-image-host/second-frame.jpg\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"task_id": "861309198188019719",
"task_status": "submitted",
"task_info": {},
"created_at": 1773380633979,
"updated_at": 1773380633979
}
}当单张源图片不足以满足需求,而你希望 Kling 基于多张图片参考构建运动时,请使用此端点。
调用前准备
- 在
image_list中准备 1 到 4 张图片 - 使用符合 Kling 像素要求的图片;过小的缩略图会被生成任务拒绝
- 除非你明确需要选择一个与路由兼容的模型,否则请省略
model_name - 首次测试请尽量保持简单:简短的 prompt、
duration: 5,且不要添加额外的回调设置 - 不要在此路由中发送图生视频的蒙版字段,例如
static_mask或dynamic_masks
任务流程
1
提交多图请求
发送图片列表、prompt 和 duration,然后保存返回的 Kling
task_id。2
轮询任务
继续使用获取一个 Kling 任务,直到任务进入终态。
3
保存结果
如果你需要在提供方交付 URL 的保留期限之外继续保存视频,请存储已完成的视频。
完整参数说明请参阅官方 Kling 文档。
请求体
application/json
最后修改于 2026年6月26日
⌘I
cURL
curl https://api.cometapi.com/kling/v1/videos/multi-image2video \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image_list": [
{
"image": "https://your-image-host/first-frame.jpg"
},
{
"image": "https://your-image-host/second-frame.jpg"
}
],
"prompt": "A smooth transition between the two reference moments",
"mode": "std",
"duration": "5",
"aspect_ratio": "1:1"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/multi-image2video",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image_list": [
{
"image": "https://your-image-host/first-frame.jpg"
},
{
"image": "https://your-image-host/second-frame.jpg"
}
],
"prompt": "A smooth transition between the two reference moments",
"mode": "std",
"duration": "5",
"aspect_ratio": "1:1"
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/multi-image2video", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image_list": [
{
"image": "https://your-image-host/first-frame.jpg"
},
{
"image": "https://your-image-host/second-frame.jpg"
}
],
"prompt": "A smooth transition between the two reference moments",
"mode": "std",
"duration": "5",
"aspect_ratio": "1:1"
}),
});
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/multi-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_list' => [
[
'image' => 'https://your-image-host/first-frame.jpg'
],
[
'image' => 'https://your-image-host/second-frame.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/multi-image2video"
payload := strings.NewReader("{\n \"image_list\": [\n {\n \"image\": \"https://your-image-host/first-frame.jpg\"\n },\n {\n \"image\": \"https://your-image-host/second-frame.jpg\"\n }\n ]\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/multi-image2video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image_list\": [\n {\n \"image\": \"https://your-image-host/first-frame.jpg\"\n },\n {\n \"image\": \"https://your-image-host/second-frame.jpg\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/multi-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_list\": [\n {\n \"image\": \"https://your-image-host/first-frame.jpg\"\n },\n {\n \"image\": \"https://your-image-host/second-frame.jpg\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"task_id": "861309198188019719",
"task_status": "submitted",
"task_info": {},
"created_at": 1773380633979,
"updated_at": 1773380633979
}
}