Trasy modeli
Utwórz zadanie Kling przekształcające obraz w wideo dla wybranego modelu
Utwórz wideo Kling z obrazu źródłowego za pomocą ścieżki właściwej dla modelu, a następnie pobierz je przy użyciu identyfikatora zadania.
POST
/
image-to-video
/
{model}
cURL
curl https://api.cometapi.com/image-to-video/kling-3.0-turbo \
-X POST \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-raw '{
"contents": [
{
"type": "prompt",
"text": "The camera slowly moves closer to the scene."
},
{
"type": "first_frame",
"url": "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg"
}
],
"settings": {
"resolution": "720p",
"duration": 5
}
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/image-to-video/kling-3.0-turbo",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"contents": [
{
"type": "prompt",
"text": "The camera slowly moves closer to the scene.",
},
{
"type": "first_frame",
"url": "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg",
},
],
"settings": {
"resolution": "720p",
"duration": 5
},
},
)
response.raise_for_status()
print(response.json()["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/image-to-video/kling-3.0-turbo",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
contents: [
{ type: "prompt", text: "The camera slowly moves closer to the scene." },
{
type: "first_frame",
url: "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg",
},
],
settings: {
resolution: "720p",
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/image-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([
'contents' => [
[
'type' => 'prompt',
'text' => 'The camera slowly moves closer to the scene.'
],
[
'type' => 'first_frame',
'url' => 'https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg'
]
]
]),
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/image-to-video/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The camera slowly moves closer to the scene.\"\n },\n {\n \"type\": \"first_frame\",\n \"url\": \"https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg\"\n }\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/image-to-video/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The camera slowly moves closer to the scene.\"\n },\n {\n \"type\": \"first_frame\",\n \"url\": \"https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/image-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 \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The camera slowly moves closer to the scene.\"\n },\n {\n \"type\": \"first_frame\",\n \"url\": \"https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}Wyślij obraz źródłowy do
Jeśli używasz innego obrazu, zastąp adres URL obrazu publicznym adresem URL lub danymi JPG/PNG zakodowanymi w Base64 dla obrazu źródłowego. Wyślij tę treść do
Zapisz
POST /image-to-video/{model}, aby utworzyć zadanie generowania wideo. Możesz dodać Prompt opisujący ruch. Odpowiedź zawiera id, którego użyjesz do pobrania wyniku.
Wybierz model
Umieść identyfikator modelu w adresie URL. Nie dodawaj pola model do treści JSON.| Identyfikator modelu | Rozdzielczość | Czas trwania | Dźwięk |
|---|---|---|---|
kling-4.0 | 720p, 1080p | Liczba całkowita od 3 do 30 sekund | Pomiń audio |
kling-3.0-turbo | 720p, 1080p | Liczba całkowita od 3 do 15 sekund | Pomiń audio |
kling-3.0 | 720p, 1080p, 4k | Liczba całkowita od 3 do 15 sekund | 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 |
kling-4.0 obsługuje first_frame, middle_frame i last_frame; uwzględnij first_frame podczas używania last_frame. kling-3.0-turbo obsługuje wyłącznie first_frame. kling-2.5-turbo,
kling-3.0, a także kling-2.6 również obsługują last_frame; uwzględnij
first_frame wraz z nim. W przypadku kling-2.5-turbo i kling-2.6 kombinacja
pierwszej i ostatniej klatki wymaga 1080p.
Parametry żądania
Umieść każde dane wejściowe wcontents. Wpis prompt używa text, a wpis klatki używa url. W przypadku obrazu podaj publicznie dostępny adres URL lub dane JPG albo PNG zakodowane w Base64.
| 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. |
contents | tablica | Tak | Wpisy danych wejściowych. Uwzględnij obraz first_frame; w razie potrzeby dodaj wpis prompt lub obsługiwany przez model obraz last_frame. |
contents[].type | ciąg znaków | Tak | prompt, first_frame, lub last_frame. Uwzględnij first_frame, gdy używasz last_frame; dostępność last_frame zależy od wybranego modelu. |
contents[].text | ciąg znaków | Dla wpisu prompt | Tekst opisujący ruch. |
contents[].url | ciąg znaków | Dla wpisu klatki | Publiczny adres URL obrazu lub dane JPG albo PNG zakodowane w Base64. |
settings.resolution | ciąg znaków | Nie | Rozdzielczość wyjściowa z powyższego wiersza wybranego modelu. Wartość domyślna to 720p. |
settings.duration | liczba całkowita | Nie | Długość wideo w sekundach zgodna z powyższym wierszem 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, na który są wysyłane 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. Generowane przez niego filmy zawierają ścieżkę dźwiękową; pomiń to pole zamiast przesyłać wartość ignorowaną przez model.
Poniższe żądanie animuje jeden obraz źródłowy, tworząc pięciosekundowy film:
{
"contents": [
{
"type": "prompt",
"text": "The camera slowly moves closer to the scene."
},
{
"type": "first_frame",
"url": "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg"
}
],
"settings": {
"resolution": "720p",
"duration": 5
}
}
https://api.cometapi.com/image-to-video/kling-3.0-turbo, używając klucza API CometAPI. Panel kodu OpenAPI zawiera żądania Shell, Python i JavaScript z tą samą treścią.
Pobieranie wideo
Odpowiedź na żądanie utworzenia ma następującą strukturę:{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}
data.id. Korzystaj z operacji Pobierz zadanie Kling dla tego identyfikatora, aż zadanie osiągnie status końcowy. Odczytaj adres URL wideo z tablicy outputs zadania.Parametry ścieżki
Treść
application/json
Image-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/image-to-video/kling-3.0-turbo \
-X POST \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-raw '{
"contents": [
{
"type": "prompt",
"text": "The camera slowly moves closer to the scene."
},
{
"type": "first_frame",
"url": "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg"
}
],
"settings": {
"resolution": "720p",
"duration": 5
}
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/image-to-video/kling-3.0-turbo",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"contents": [
{
"type": "prompt",
"text": "The camera slowly moves closer to the scene.",
},
{
"type": "first_frame",
"url": "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg",
},
],
"settings": {
"resolution": "720p",
"duration": 5
},
},
)
response.raise_for_status()
print(response.json()["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/image-to-video/kling-3.0-turbo",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
contents: [
{ type: "prompt", text: "The camera slowly moves closer to the scene." },
{
type: "first_frame",
url: "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg",
},
],
settings: {
resolution: "720p",
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/image-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([
'contents' => [
[
'type' => 'prompt',
'text' => 'The camera slowly moves closer to the scene.'
],
[
'type' => 'first_frame',
'url' => 'https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg'
]
]
]),
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/image-to-video/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The camera slowly moves closer to the scene.\"\n },\n {\n \"type\": \"first_frame\",\n \"url\": \"https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg\"\n }\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/image-to-video/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The camera slowly moves closer to the scene.\"\n },\n {\n \"type\": \"first_frame\",\n \"url\": \"https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/image-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 \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"The camera slowly moves closer to the scene.\"\n },\n {\n \"type\": \"first_frame\",\n \"url\": \"https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}