Kling
应用 Kling 视频特效
通过 CometAPI 使用 Kling 视频特效 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值 - 不要依赖固定的公开枚举列表;特效可用性会因模型通道和场景系列而变化
任务流程
1
提交特效请求
发送
effect_scene 以及匹配的 input 对象,并保存返回的任务 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
}
}