Kling
從多張圖片產生 Kling 圖像
使用 CometAPI 的 Kling 多圖生圖端點,根據主體、場景與風格圖片參考產生新圖像。
POST
/
kling
/
v1
/
images
/
multi-image2image
cURL
curl https://api.cometapi.com/kling/v1/images/multi-image2image \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_name": "kling-v2-1",
"prompt": "Two product mascots standing together in a bright studio scene",
"subject_image_list": [
{
"subject_image": "https://your-image-host/subject-1.png"
},
{
"subject_image": "https://your-image-host/subject-2.png"
}
],
"scene_image": "https://your-image-host/scene.png",
"style_image": "https://your-image-host/style.png",
"n": 1,
"aspect_ratio": "1:1"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/images/multi-image2image",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"model_name": "kling-v2-1",
"prompt": "Two product mascots standing together in a bright studio scene",
"subject_image_list": [
{
"subject_image": "https://your-image-host/subject-1.png"
},
{
"subject_image": "https://your-image-host/subject-2.png"
}
],
"scene_image": "https://your-image-host/scene.png",
"style_image": "https://your-image-host/style.png",
"n": 1,
"aspect_ratio": "1:1"
},
)
result = response.json()
print(result["code"], result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/images/multi-image2image", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model_name": "kling-v2-1",
"prompt": "Two product mascots standing together in a bright studio scene",
"subject_image_list": [
{
"subject_image": "https://your-image-host/subject-1.png"
},
{
"subject_image": "https://your-image-host/subject-2.png"
}
],
"scene_image": "https://your-image-host/scene.png",
"style_image": "https://your-image-host/style.png",
"n": 1,
"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/images/multi-image2image",
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([
'subject_image_list' => [
[
'subject_image' => 'https://your-image-host/subject-1.png'
],
[
'subject_image' => 'https://your-image-host/subject-2.png'
]
]
]),
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/images/multi-image2image"
payload := strings.NewReader("{\n \"subject_image_list\": [\n {\n \"subject_image\": \"https://your-image-host/subject-1.png\"\n },\n {\n \"subject_image\": \"https://your-image-host/subject-2.png\"\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/images/multi-image2image")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"subject_image_list\": [\n {\n \"subject_image\": \"https://your-image-host/subject-1.png\"\n },\n {\n \"subject_image\": \"https://your-image-host/subject-2.png\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/images/multi-image2image")
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 \"subject_image_list\": [\n {\n \"subject_image\": \"https://your-image-host/subject-1.png\"\n },\n {\n \"subject_image\": \"https://your-image-host/subject-2.png\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"data": {
"task_id": "<string>",
"task_status": "submitted",
"created_at": 123,
"updated_at": 123,
"task_status_msg": "<string>",
"task_info": {
"external_task_id": "<string>"
},
"task_result": {}
},
"request_id": "<string>"
}當你希望 Kling 根據多個主體參考,再加上可選的場景或風格參考來產生一張圖像時,請使用此端點。
呼叫前準備
- 在
subject_image_list中提供 1 到 4 張圖片 - 新請求請使用
model_name: kling-v2-1 - 只有在核心主體構圖已經可行時,才加入
scene_image或style_image - 將此視為非同步產生路由,並保存回傳的 task id
任務流程
1
提交圖像產生任務
傳送主體圖片清單與 prompt,然後儲存回傳的 task id。
2
輪詢任務
使用對應的 Kling 圖像查詢路徑輪詢回傳的任務,直到任務進入終止狀態。
3
保存結果
如果你需要持久存取,請將產生的圖像儲存到你自己的儲存空間中。
如需完整的參數參考,請參閱官方 Kling 文件。
主體
application/json
最後修改於 2026年6月26日
⌘I
cURL
curl https://api.cometapi.com/kling/v1/images/multi-image2image \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model_name": "kling-v2-1",
"prompt": "Two product mascots standing together in a bright studio scene",
"subject_image_list": [
{
"subject_image": "https://your-image-host/subject-1.png"
},
{
"subject_image": "https://your-image-host/subject-2.png"
}
],
"scene_image": "https://your-image-host/scene.png",
"style_image": "https://your-image-host/style.png",
"n": 1,
"aspect_ratio": "1:1"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/images/multi-image2image",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"model_name": "kling-v2-1",
"prompt": "Two product mascots standing together in a bright studio scene",
"subject_image_list": [
{
"subject_image": "https://your-image-host/subject-1.png"
},
{
"subject_image": "https://your-image-host/subject-2.png"
}
],
"scene_image": "https://your-image-host/scene.png",
"style_image": "https://your-image-host/style.png",
"n": 1,
"aspect_ratio": "1:1"
},
)
result = response.json()
print(result["code"], result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/images/multi-image2image", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model_name": "kling-v2-1",
"prompt": "Two product mascots standing together in a bright studio scene",
"subject_image_list": [
{
"subject_image": "https://your-image-host/subject-1.png"
},
{
"subject_image": "https://your-image-host/subject-2.png"
}
],
"scene_image": "https://your-image-host/scene.png",
"style_image": "https://your-image-host/style.png",
"n": 1,
"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/images/multi-image2image",
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([
'subject_image_list' => [
[
'subject_image' => 'https://your-image-host/subject-1.png'
],
[
'subject_image' => 'https://your-image-host/subject-2.png'
]
]
]),
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/images/multi-image2image"
payload := strings.NewReader("{\n \"subject_image_list\": [\n {\n \"subject_image\": \"https://your-image-host/subject-1.png\"\n },\n {\n \"subject_image\": \"https://your-image-host/subject-2.png\"\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/images/multi-image2image")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"subject_image_list\": [\n {\n \"subject_image\": \"https://your-image-host/subject-1.png\"\n },\n {\n \"subject_image\": \"https://your-image-host/subject-2.png\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/images/multi-image2image")
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 \"subject_image_list\": [\n {\n \"subject_image\": \"https://your-image-host/subject-1.png\"\n },\n {\n \"subject_image\": \"https://your-image-host/subject-2.png\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"data": {
"task_id": "<string>",
"task_status": "submitted",
"created_at": 123,
"updated_at": 123,
"task_status_msg": "<string>",
"task_info": {
"external_task_id": "<string>"
},
"task_result": {}
},
"request_id": "<string>"
}