模型接口
创建 Kling 动作控制视频
根据人物图像和参考动作视频创建 Kling 动作控制任务。
POST
/
motion-control
/
{model}
cURL
curl https://api.cometapi.com/motion-control/kling-2.6 \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"contents": [
{
"type": "prompt",
"text": "The character performs the dance shown in the reference video."
},
{
"type": "image",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png"
},
{
"type": "video",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4"
}
],
"settings": {
"resolution": "720p",
"character_orientation": "video",
"audio": "off"
}
}
JSONimport os
import requests
response = requests.post(
"https://api.cometapi.com/motion-control/kling-2.6",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"contents": [
{
"type": "prompt",
"text": "The character performs the dance shown in the reference video.",
},
{
"type": "image",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png",
},
{
"type": "video",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4",
},
],
"settings": {
"resolution": "720p",
"character_orientation": "video",
"audio": "off",
},
},
)
response.raise_for_status()
result = response.json()
print(result["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/motion-control/kling-2.6",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"contents": [
{
"type": "prompt",
"text": "The character performs the dance shown in the reference video."
},
{
"type": "image",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png"
},
{
"type": "video",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4"
}
],
"settings": {
"resolution": "720p",
"character_orientation": "video",
"audio": "off"
}
}),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
console.log(result.data.id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/motion-control/{model}",
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([
'contents' => [
[
'type' => 'prompt',
'text' => 'The character performs the dance shown in the reference video.'
],
[
'type' => 'image',
'url' => 'https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png'
],
[
'type' => 'video',
'url' => 'https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4'
]
],
'settings' => [
'resolution' => '720p',
'character_orientation' => 'video',
'audio' => 'off'
]
]),
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/motion-control/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The character performs the dance shown in the reference video.\"\n },\n {\n \"type\": \"image\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png\"\n },\n {\n \"type\": \"video\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4\"\n }\n ],\n \"settings\": {\n \"resolution\": \"720p\",\n \"character_orientation\": \"video\",\n \"audio\": \"off\"\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/motion-control/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The character performs the dance shown in the reference video.\"\n },\n {\n \"type\": \"image\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png\"\n },\n {\n \"type\": \"video\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4\"\n }\n ],\n \"settings\": {\n \"resolution\": \"720p\",\n \"character_orientation\": \"video\",\n \"audio\": \"off\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/motion-control/{model}")
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 \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The character performs the dance shown in the reference video.\"\n },\n {\n \"type\": \"image\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png\"\n },\n {\n \"type\": \"video\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4\"\n }\n ],\n \"settings\": {\n \"resolution\": \"720p\",\n \"character_orientation\": \"video\",\n \"audio\": \"off\"\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}使用
请将人物图像和参考视频作为可公开访问的 URL 使用。将
要让人物图像动起来,请将此请求正文发送到
响应会返回异步任务的
将
POST /motion-control/{model} 通过参考视频中的动作让人物图像动起来。该请求会创建一个异步任务。
选择模型
| 模型 ID | 分辨率 | settings.audio |
|---|---|---|
kling-3.0 | 720p, 1080p | original, off |
kling-2.6 | 720p, 1080p | original, off |
settings.audio 设为 original 以保留参考视频中的音频,或设为 off 以生成静音输出。
图像必须为 JPG 或 PNG 格式,大小不超过 50 MB,且每条边至少为 300 像素。请使用时长至少 3 秒、大小不超过 100 MB 的 MP4 或 MOV 参考视频。使用 character_orientation: image 时,视频最长可达 10 秒;使用 video 时,最长可达 30 秒。
请求参数
| 字段 | 必填 | 说明 |
|---|---|---|
路径 model | 是 | URL 中的模型 ID:kling-3.0 或 kling-2.6。请勿将其添加到请求正文中。 |
contents | 是 | 包含一个 image 项和一个 video 项的数组。添加 prompt 项以描述场景。 |
contents[].type | 是 | image 用于人物的 video、用于动作参考的 prompt,或用于文本引导的 |
contents[].url | 对于图像和视频项 | 人物图像或参考动作视频的公开 URL。 |
contents[].text | 对于 prompt 项 | 生成场景所需的文本引导。 |
settings.resolution | 否 | 输出分辨率:720p 或 1080p。如果省略,请求将使用 720p. |
settings.character_orientation | 是 | image 使用图像中的人物朝向;video 使用参考视频中的朝向。 |
settings.audio | 否 | 将 original 设为保留参考音频,或将 off 设为禁用参考音频。请显式设置该值。 |
options.callback_url | 否 | 用于接收任务状态回调的 HTTPS URL。 |
options.external_task_id | 否 | 用于关联的自定义任务标识符;请保留返回的 data.id 以供查询。 |
options.watermark_info.enabled | 否 | 设为 true 以请求添加水印。 |
POST /motion-control/kling-2.6。使用自己的人物和动作时,请将媒体 URL 替换为您自己可访问的文件:
{
"contents": [
{
"type": "prompt",
"text": "The character performs the dance shown in the reference video."
},
{
"type": "image",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png"
},
{
"type": "video",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4"
}
],
"settings": {
"resolution": "720p",
"character_orientation": "video",
"audio": "off"
}
}
id:
{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}
data.id 值与 获取 Kling 任务 结合使用,直到任务完成。从任务的 outputs 数组中读取已完成视频的 URL。如果需要持久访问,请将视频存储在您自己的存储中。
OpenAPI 面板包含对应的 Shell、Python 和 JavaScript 请求。有关更多输入详情,请参阅 Kling 动作控制 API 参考.请求体
application/json
Motion-control request fields exposed by the CometAPI route. The model ID is a path parameter, not a body field.
最后修改于 2026年9月25日
⌘I
cURL
curl https://api.cometapi.com/motion-control/kling-2.6 \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"contents": [
{
"type": "prompt",
"text": "The character performs the dance shown in the reference video."
},
{
"type": "image",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png"
},
{
"type": "video",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4"
}
],
"settings": {
"resolution": "720p",
"character_orientation": "video",
"audio": "off"
}
}
JSONimport os
import requests
response = requests.post(
"https://api.cometapi.com/motion-control/kling-2.6",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"contents": [
{
"type": "prompt",
"text": "The character performs the dance shown in the reference video.",
},
{
"type": "image",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png",
},
{
"type": "video",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4",
},
],
"settings": {
"resolution": "720p",
"character_orientation": "video",
"audio": "off",
},
},
)
response.raise_for_status()
result = response.json()
print(result["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/motion-control/kling-2.6",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"contents": [
{
"type": "prompt",
"text": "The character performs the dance shown in the reference video."
},
{
"type": "image",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png"
},
{
"type": "video",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4"
}
],
"settings": {
"resolution": "720p",
"character_orientation": "video",
"audio": "off"
}
}),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
console.log(result.data.id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/motion-control/{model}",
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([
'contents' => [
[
'type' => 'prompt',
'text' => 'The character performs the dance shown in the reference video.'
],
[
'type' => 'image',
'url' => 'https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png'
],
[
'type' => 'video',
'url' => 'https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4'
]
],
'settings' => [
'resolution' => '720p',
'character_orientation' => 'video',
'audio' => 'off'
]
]),
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/motion-control/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The character performs the dance shown in the reference video.\"\n },\n {\n \"type\": \"image\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png\"\n },\n {\n \"type\": \"video\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4\"\n }\n ],\n \"settings\": {\n \"resolution\": \"720p\",\n \"character_orientation\": \"video\",\n \"audio\": \"off\"\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/motion-control/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The character performs the dance shown in the reference video.\"\n },\n {\n \"type\": \"image\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png\"\n },\n {\n \"type\": \"video\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4\"\n }\n ],\n \"settings\": {\n \"resolution\": \"720p\",\n \"character_orientation\": \"video\",\n \"audio\": \"off\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/motion-control/{model}")
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 \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The character performs the dance shown in the reference video.\"\n },\n {\n \"type\": \"image\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/multi-3.ng.png\"\n },\n {\n \"type\": \"video\",\n \"url\": \"https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dance.mp4\"\n }\n ],\n \"settings\": {\n \"resolution\": \"720p\",\n \"character_orientation\": \"video\",\n \"audio\": \"off\"\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}