Trasy modeli
Utwórz zadanie Kling generujące film z tekstu dla wybranego modelu
Utwórz film Kling na podstawie tekstowego Promptu, korzystając ze ścieżki właściwej dla modelu, a następnie pobierz film za pomocą identyfikatora zadania.
POST
/
text-to-video
/
{model}
cURL
curl https://api.cometapi.com/text-to-video/kling-3.0-turbo \
-X POST \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-raw '{
"prompt": "A paper boat drifts across a calm pond at sunrise.",
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5
}
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/text-to-video/kling-3.0-turbo",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"prompt": "A paper boat drifts across a calm pond at sunrise.",
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5
},
},
)
response.raise_for_status()
print(response.json()["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/text-to-video/kling-3.0-turbo",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "A paper boat drifts across a calm pond at sunrise.",
settings: {
resolution: "720p",
aspect_ratio: "16:9",
duration: 5,
},
}),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log((await response.json()).data.id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/text-to-video/{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([
'prompt' => 'A paper boat drifts across a calm pond at sunrise.'
]),
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/text-to-video/{model}"
payload := strings.NewReader("{\n \"prompt\": \"A paper boat drifts across a calm pond at sunrise.\"\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/text-to-video/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"A paper boat drifts across a calm pond at sunrise.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/text-to-video/{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 \"prompt\": \"A paper boat drifts across a calm pond at sunrise.\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}Wyślij Prompt do
Wyślij tę treść do
Zapisz
POST /text-to-video/{model}, aby utworzyć zadanie generowania filmu. Odpowiedź zawiera id, którego użyjesz do pobrania wyniku.
Wybierz model
Umieść identyfikator modelu w adresie URL. Nie dodawaj pola modelu do treści JSON.| Identyfikator modelu | Rozdzielczość | Czas trwania | Dźwięk |
|---|---|---|---|
kling-4.0 | 720p, 1080p | Od 3 do 30 sekund, liczba całkowita | Pomiń audio |
kling-3.0-turbo | 720p, 1080p | Od 3 do 15 sekund, liczba całkowita | Pomiń audio |
kling-3.0 | 720p, 1080p, 4k | Od 3 do 15 sekund, liczba całkowita | native lub off |
kling-2.6 | 720p, 1080p | 5 lub 10 sekund | native lub off; użyj 1080p z native |
kling-2.5-turbo | 720p, 1080p | 5 lub 10 sekund | Pomiń audio |
Parametry żądania
| Pole | Typ | Wymagane | Opis |
|---|---|---|---|
Ścieżka model | ciąg znaków | Tak | Identyfikator modelu w adresie URL. Wybierz identyfikator z powyższej tabeli; nie dodawaj go do treści żądania. |
prompt | ciąg znaków | Tak | Opis filmu do wygenerowania. |
settings.resolution | ciąg znaków | Nie | Rozdzielczość wyjściowa z powyższego wiersza wybranego modelu. Wartość domyślna to 720p. |
settings.aspect_ratio | ciąg znaków | Nie | Proporcje obrazu wyjściowego: 21:9 (tylko kling-4.0), 16:9, 9:16 lub 1:1. Wartość domyślna to 16:9. |
settings.duration | liczba całkowita | Nie | Długość filmu w sekundach z powyższego wiersza wybranego modelu. Wartość domyślna to 10 dla kling-4.0 i 5 dla pozostałych modeli. Prześlij liczbę całkowitą, a nie ciąg znaków. |
settings.multi_shot | wartość logiczna | Nie | Tylko dla kling-3.0 oficjalna wartość domyślna to true. Ustaw true dla wielu ujęć lub false dla jednego ujęcia. Gdy używasz tego pola, ustaw wartość jawnie. |
settings.audio | ciąg znaków | Nie | Dla kling-3.0 lub kling-2.6 ustaw native, aby wygenerować dźwięk, lub off, aby go nie generować. Gdy używasz tego pola, ustaw wartość jawnie. |
options.callback_url | ciąg znaków | Nie | Publiczny adres URL odbierający aktualizacje zadania. |
options.external_task_id | ciąg znaków | Nie | Twój identyfikator służący do powiązania zadania z aplikacją. |
options.watermark_info | obiekt | Nie | Konfiguracja znaku wodnego dla wyniku. |
kling-4.0 nie udostępnia przełącznika settings.audio. Jego filmy zawierają ścieżkę dźwiękową; pomiń to pole zamiast przesyłać wartość, którą model zignoruje.
Poniższe żądanie tworzy pięciosekundowy film za pomocą kling-3.0-turbo:
{
"prompt": "A paper boat drifts across a calm pond at sunrise.",
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5
}
}
https://api.cometapi.com/text-to-video/kling-3.0-turbo, używając klucza API CometAPI. Panel kodu OpenAPI udostępnia żądania dla Shell, Python i JavaScript z tą samą treścią.
Pobierz film
Odpowiedź na żądanie utworzenia ma następującą postać:{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}
data.id. Użyj funkcji Pobierz zadanie Kling z tym identyfikatorrem, aż zadanie osiągnie stan końcowy. Odczytaj adres URL filmu z tablicy outputs zadania.Parametry ścieżki
Treść
application/json
Text-to-video request fields exposed by the CometAPI route. The model ID is a path parameter, not a body field.
Odpowiedź
200 - application/json
The task was created. Use data.id to retrieve its status and video output.
Ostatnia modyfikacja 13 listopada 2026
⌘I
cURL
curl https://api.cometapi.com/text-to-video/kling-3.0-turbo \
-X POST \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-raw '{
"prompt": "A paper boat drifts across a calm pond at sunrise.",
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5
}
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/text-to-video/kling-3.0-turbo",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"prompt": "A paper boat drifts across a calm pond at sunrise.",
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5
},
},
)
response.raise_for_status()
print(response.json()["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/text-to-video/kling-3.0-turbo",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "A paper boat drifts across a calm pond at sunrise.",
settings: {
resolution: "720p",
aspect_ratio: "16:9",
duration: 5,
},
}),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log((await response.json()).data.id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/text-to-video/{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([
'prompt' => 'A paper boat drifts across a calm pond at sunrise.'
]),
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/text-to-video/{model}"
payload := strings.NewReader("{\n \"prompt\": \"A paper boat drifts across a calm pond at sunrise.\"\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/text-to-video/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"A paper boat drifts across a calm pond at sunrise.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/text-to-video/{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 \"prompt\": \"A paper boat drifts across a calm pond at sunrise.\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}