Kling
Kling 動画エフェクトを適用する
CometAPI 経由で Kling Video Effects API を使用し、POST /kling/v1/videos/effects で動画にスタイライズされたエフェクトを適用し、エフェクトパラメータを制御します。
POST
/
kling
/
v1
/
videos
/
effects
cURL
curl https://api.cometapi.com/kling/v1/videos/effects \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"effect_scene": "hug",
"input": {
"mode": "std",
"images": [
"https://your-image-host/person-a.jpg",
"https://your-image-host/person-b.jpg"
],
"duration": "5"
}
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/effects",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"effect_scene": "hug",
"input": {
"mode": "std",
"images": [
"https://your-image-host/person-a.jpg",
"https://your-image-host/person-b.jpg"
],
"duration": "5"
}
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/effects", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"effect_scene": "hug",
"input": {
"mode": "std",
"images": [
"https://your-image-host/person-a.jpg",
"https://your-image-host/person-b.jpg"
],
"duration": "5"
}
}),
});
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/effects",
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([
'effect_scene' => 'hug',
'input' => [
'mode' => 'std',
'images' => [
'https://your-image-host/person-a.jpg',
'https://your-image-host/person-b.jpg'
],
'duration' => '5'
]
]),
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/effects"
payload := strings.NewReader("{\n \"effect_scene\": \"hug\",\n \"input\": {\n \"mode\": \"std\",\n \"images\": [\n \"https://your-image-host/person-a.jpg\",\n \"https://your-image-host/person-b.jpg\"\n ],\n \"duration\": \"5\"\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/effects")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"effect_scene\": \"hug\",\n \"input\": {\n \"mode\": \"std\",\n \"images\": [\n \"https://your-image-host/person-a.jpg\",\n \"https://your-image-host/person-b.jpg\"\n ],\n \"duration\": \"5\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/effects")
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 \"effect_scene\": \"hug\",\n \"input\": {\n \"mode\": \"std\",\n \"images\": [\n \"https://your-image-host/person-a.jpg\",\n \"https://your-image-host/person-b.jpg\"\n ],\n \"duration\": \"5\"\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"task_id": "2032273960331935744",
"task_status": "submitted",
"task_info": {},
"created_at": 1773366844624,
"updated_at": 1773366844624
}
}このエンドポイントを使用すると、Kling のプリセットエフェクトシーンの1つを適用し、入力アセットを新しい短い動画に変換できます。
エフェクトシーンを選ぶ
- 単一画像のエフェクトでは、
effect_sceneに加えてinput.imageとinput.durationを使用します - 2人のインタラクションエフェクトでは、
effect_sceneに加えて、ちょうど2枚の画像を含むinput.imagesを使用します - 入力画像は Kling のピクセル要件を満たしている必要があります。小さすぎるサムネイルは生成タスクで拒否されます
- 正確なアセット形式は選択したエフェクトによって異なりますが、リクエストでは常にエフェクト設定を
input内に含めます - Kling で現在利用可能なエフェクトシーンを使用してください。CometAPI は不明な
effect_sceneの値を拒否します - 公開された enum の固定リストに依存しないでください。エフェクトの利用可否は model track や scene family によって変わります
タスクフロー
1
エフェクトリクエストを送信する
effect_scene と対応する input オブジェクトを送信し、返された task id を保存します。2
タスクをポーリングする
エフェクトジョブが完了するまで、Kling タスクを取得する を続けてください。
3
最終アセットを保存する
安定した保持が必要な場合は、完成したエフェクト動画をダウンロードまたはミラーリングしてください。
完全なパラメータリファレンスについては、Kling の公式ドキュメント を参照してください。
ボディ
application/json
最終更新日 2026年6月25日
⌘I
cURL
curl https://api.cometapi.com/kling/v1/videos/effects \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"effect_scene": "hug",
"input": {
"mode": "std",
"images": [
"https://your-image-host/person-a.jpg",
"https://your-image-host/person-b.jpg"
],
"duration": "5"
}
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/effects",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"effect_scene": "hug",
"input": {
"mode": "std",
"images": [
"https://your-image-host/person-a.jpg",
"https://your-image-host/person-b.jpg"
],
"duration": "5"
}
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/effects", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"effect_scene": "hug",
"input": {
"mode": "std",
"images": [
"https://your-image-host/person-a.jpg",
"https://your-image-host/person-b.jpg"
],
"duration": "5"
}
}),
});
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/effects",
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([
'effect_scene' => 'hug',
'input' => [
'mode' => 'std',
'images' => [
'https://your-image-host/person-a.jpg',
'https://your-image-host/person-b.jpg'
],
'duration' => '5'
]
]),
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/effects"
payload := strings.NewReader("{\n \"effect_scene\": \"hug\",\n \"input\": {\n \"mode\": \"std\",\n \"images\": [\n \"https://your-image-host/person-a.jpg\",\n \"https://your-image-host/person-b.jpg\"\n ],\n \"duration\": \"5\"\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/effects")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"effect_scene\": \"hug\",\n \"input\": {\n \"mode\": \"std\",\n \"images\": [\n \"https://your-image-host/person-a.jpg\",\n \"https://your-image-host/person-b.jpg\"\n ],\n \"duration\": \"5\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/effects")
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 \"effect_scene\": \"hug\",\n \"input\": {\n \"mode\": \"std\",\n \"images\": [\n \"https://your-image-host/person-a.jpg\",\n \"https://your-image-host/person-b.jpg\"\n ],\n \"duration\": \"5\"\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"task_id": "2032273960331935744",
"task_status": "submitted",
"task_info": {},
"created_at": 1773366844624,
"updated_at": 1773366844624
}
}