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 的其中一個預設特效場景,將輸入素材轉換為新的短影片。
選擇特效場景
- 單張圖片特效使用
effect_scene搭配input.image與input.duration - 雙人互動特效使用
effect_scene搭配input.images,且必須剛好提供兩張圖片 - 輸入圖片必須符合 Kling 的像素要求;過小的縮圖會被生成任務拒絕
- 確切的素材格式取決於所選特效,但請求一律會將特效設定包在
input內 - 請使用目前 Kling 可用的特效場景;CometAPI 會拒絕未知的
effect_scene值 - 避免依賴固定的公開 enum 清單;特效可用性會隨 model track 與場景家族而變動
任務流程
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
}
}