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 に 1 枚の画像を生成させたい場合は、このエンドポイントを使用します。
呼び出す前に
subject_image_listに 1 ~ 4 枚の画像を指定します- 新しいリクエストには
model_name: kling-v2-1を使用します - コアとなる被写体構図がすでに機能している場合にのみ
scene_imageまたはstyle_imageを追加します - これは非同期生成ルートとして扱い、返された task id を保存します
タスクの流れ
1
画像生成タスクを送信
被写体画像のリストとプロンプトを送信し、返された 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>"
}