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,且不要加入額外的 callback 設定 - 請勿在此路由上傳送 image-to-video 的遮罩欄位,例如
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
}
}