Trasy modeli
Utwórz wideo Kling ze sterowaniem ruchem
Utwórz zadanie Kling ze sterowaniem ruchem na podstawie obrazu postaci i referencyjnego wideo ruchu.
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"
}
}Użyj
Użyj obrazu postaci i wideo referencyjnego jako publicznie dostępnych adresów URL. Ustaw
Aby animować obraz postaci, wyślij tę treść żądania do
Odpowiedź zwraca
Użyj wartości
POST /motion-control/{model}, aby animować obraz postaci ruchem z wideo referencyjnego. Żądanie tworzy zadanie asynchroniczne.
Wybierz model
| Identyfikator modelu | Rozdzielczość | settings.audio |
|---|---|---|
kling-3.0 | 720p, 1080p | original, off |
kling-2.6 | 720p, 1080p | original, off |
settings.audio na original, aby zachować dźwięk z wideo referencyjnego, lub na off, aby uzyskać wyjście bez dźwięku.
Obraz musi być w formacie JPG lub PNG, mieć maksymalnie 50 MB i co najmniej 300 pikseli na każdym boku. Użyj referencyjnego wideo MP4 lub MOV trwającego co najmniej 3 sekundy i mającego maksymalnie 100 MB. W przypadku character_orientation: image wideo może trwać do 10 sekund, a w przypadku video — do 30 sekund.
Parametry żądania
| Pole | Wymagane | Opis |
|---|---|---|
Ścieżka model | Tak | Identyfikator modelu w adresie URL: kling-3.0 lub kling-2.6. Nie dodawaj go do treści żądania. |
contents | Tak | Tablica zawierająca jeden element image i jeden element video. Dodaj element prompt, aby opisać scenę. |
contents[].type | Tak | image dla postaci, video dla referencji ruchu lub prompt dla wskazówek tekstowych. |
contents[].url | Dla elementów obrazu i wideo | Publiczny adres URL obrazu postaci lub referencyjnego wideo ruchu. |
contents[].text | Dla elementu prompt | Wymagane wskazówki tekstowe dotyczące generowanej sceny. |
settings.resolution | Nie | Rozdzielczość wyjściowa: 720p lub 1080p. Jeśli parametr zostanie pominięty, żądanie używa 720p. |
settings.character_orientation | Tak | image używa orientacji postaci z obrazu; video używa wideo referencyjnego. |
settings.audio | Nie | Ustaw original, aby zachować dźwięk referencyjny, lub off, aby go wyłączyć. Ustaw wartość jawnie. |
options.callback_url | Nie | Adres URL HTTPS odbierający wywołania zwrotne dotyczące stanu zadania. |
options.external_task_id | Nie | Własny identyfikator zadania do korelacji; zachowaj zwrócone data.id na potrzeby zapytań. |
options.watermark_info.enabled | Nie | Ustaw wartość true, aby zażądać znaku wodnego. |
POST /motion-control/kling-2.6. Podczas używania własnej postaci i ruchu zastąp adresy URL mediów własnymi dostępnymi plikami:
{
"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 dla zadania asynchronicznego:
{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}
data.id z Pobierz zadanie Kling aż zadanie zostanie ukończone. Odczytaj adres URL gotowego wideo z tablicy outputs zadania. Zapisz wideo we własnej pamięci masowej, jeśli potrzebujesz trwałego dostępu.
Panel OpenAPI zawiera odpowiadające żądania w Shell, Python i JavaScript. Więcej informacji o danych wejściowych znajdziesz w Dokumentacja API Kling ze sterowaniem ruchem.Parametry ścieżki
Treść
application/json
Motion-control request fields exposed by the CometAPI route. The model ID is a path parameter, not a body field.
Odpowiedź
200 - application/json
Task created. Store data.id for a GET /tasks query.
Ostatnia modyfikacja 25 września 2026
⌘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"
}
}