Kling
Kling으로 이미지 인식하기
CometAPI POST /kling/v1/videos/image-recognize를 사용해 이미지에 대해 Kling Image Recognize를 실행하고 비디오 생성 워크플로를 위한 인식 결과를 반환합니다.
POST
/
kling
/
v1
/
videos
/
image-recognize
cURL
curl https://api.cometapi.com/kling/v1/videos/image-recognize \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://your-image-host/portrait.jpg"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/image-recognize",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image": "https://your-image-host/portrait.jpg"
},
)
result = response.json()
print(result["code"], result.get("data", {}).get("task_id")) # the route responds with the result payload directlyconst response = await fetch("https://api.cometapi.com/kling/v1/videos/image-recognize", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image": "https://your-image-host/portrait.jpg"
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id); // the route responds with the result payload directly<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/image-recognize",
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/portrait.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/image-recognize"
payload := strings.NewReader("{\n \"image\": \"https://your-image-host/portrait.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/image-recognize")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"https://your-image-host/portrait.jpg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/image-recognize")
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/portrait.jpg\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"task_result": {
"images": [
{
"type": "head_seg",
"is_contain": true
},
{
"type": "face_seg",
"is_contain": true
},
{
"type": "cloth_seg",
"is_contain": true
},
{
"type": "object_seg",
"is_contain": true
}
]
}
}
}이 엔드포인트를 사용하면 어떤 후속 워크플로를 사용할지 결정하기 전에 Kling의 이미지 인식 검사를 실행할 수 있습니다.
반환 내용
- 이 경로는 동기식이며 인식 플래그를 직접 반환합니다
- 현재 결과는 이미지에
head_seg,face_seg,cloth_seg,object_seg같은 영역이 포함되어 있는지를 나타냅니다 - 이 플래그를 사용해 소스 이미지가 아바타, 가상 피팅, 또는 기타 에셋 기반 워크플로에 적합한지 판단할 수 있습니다
전체 파라미터 참조는 Kling 공식 문서를 참고하세요.
인증
Bearer token authentication. Use your CometAPI key.
헤더
Optional content type header.
본문
application/json
Image to analyze. Accepts an image URL or raw Base64 string (no data: prefix). Supported formats: JPG, JPEG, PNG. Max 10 MB, minimum 300 px per side, aspect ratio between 1:2.5 and 2.5:1.
⌘I
cURL
curl https://api.cometapi.com/kling/v1/videos/image-recognize \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://your-image-host/portrait.jpg"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/image-recognize",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image": "https://your-image-host/portrait.jpg"
},
)
result = response.json()
print(result["code"], result.get("data", {}).get("task_id")) # the route responds with the result payload directlyconst response = await fetch("https://api.cometapi.com/kling/v1/videos/image-recognize", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image": "https://your-image-host/portrait.jpg"
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id); // the route responds with the result payload directly<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/image-recognize",
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/portrait.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/image-recognize"
payload := strings.NewReader("{\n \"image\": \"https://your-image-host/portrait.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/image-recognize")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"https://your-image-host/portrait.jpg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/image-recognize")
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/portrait.jpg\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"task_result": {
"images": [
{
"type": "head_seg",
"is_contain": true
},
{
"type": "face_seg",
"is_contain": true
},
{
"type": "cloth_seg",
"is_contain": true
},
{
"type": "object_seg",
"is_contain": true
}
]
}
}
}