Modellrouten
Eine Kling-Bild-zu-Video-Aufgabe für ein Modell erstellen
Erstelle aus einem Ausgangsbild über eine modellspezifische Route ein Kling-Video und rufe es anschließend anhand der Aufgaben-ID ab.
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"
}
}Sende ein Ausgangsbild an
Ersetzen Sie die Bild-URL durch eine öffentliche URL oder Base64-kodierte JPG- oder PNG-Daten für Ihr Quellbild, wenn Sie ein anderes Bild verwenden. Senden Sie diesen Body mit Ihrem CometAPI-API-Schlüssel an
Speichern Sie
POST /image-to-video/{model}, um eine Videoaufgabe zu erstellen. Du kannst einen Prompt hinzufügen, um die Bewegung zu beschreiben. Die Antwort enthält id, womit du das Ergebnis abrufen kannst.
Modell auswählen
Gib die Modell-ID in der URL an. Füge dem JSON-Body kein Modellfeld hinzu.| Modell-ID | Auflösung | Dauer | Audio |
|---|---|---|---|
kling-4.0 | 720p, 1080p | Ganzzahl zwischen 3 und 30 Sekunden | Weglassen audio |
kling-3.0-turbo | 720p, 1080p | Ganzzahl zwischen 3 und 15 Sekunden | Weglassen audio |
kling-3.0 | 720p, 1080p, 4k | Ganzzahl zwischen 3 und 15 Sekunden | native oder off |
kling-2.6 | 720p, 1080p | 5 oder 10 Sekunden | native oder off; verwende 1080p mit native |
kling-2.5-turbo | 720p, 1080p | 5 oder 10 Sekunden | Weglassen audio |
kling-4.0 akzeptiert first_frame, middle_frame und last_frame; gib ein first_frame an, wenn du last_frame verwendest. kling-3.0-turbo akzeptiert nur ein first_frame. Auch kling-2.5-turbo,
kling-3.0 und kling-2.6 unterstützen ein last_frame; gib dazu ein
first_frame an. Für kling-2.5-turbo und kling-2.6 erfordert die
Kombination aus erstem und letztem Frame 1080p.
Anfrageparameter
Geben Sie jede Eingabe incontents an. Ein prompt-Eintrag verwendet text; ein Frame-Eintrag verwendet url. Geben Sie für ein Bild eine öffentlich zugängliche URL oder Base64-kodierte JPG- oder PNG-Daten an.
| Feld | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
Pfad model | string | Ja | Modell-ID in der URL. Wählen Sie eine ID aus der obigen Tabelle; fügen Sie sie nicht zum Anfrage-Body hinzu. |
contents | array | Ja | Eingabeeinträge. Fügen Sie ein first_frame-Bild hinzu; ergänzen Sie bei Bedarf einen prompt-Eintrag oder ein vom Modell unterstütztes last_frame-Bild. |
contents[].type | string | Ja | prompt, first_frame, oder last_frame. Fügen Sie einen first_frame hinzu, wenn Sie last_frame verwenden; das ausgewählte Modell bestimmt, ob last_frame verfügbar ist. |
contents[].text | string | Für einen prompt-Eintrag | Text, der die Bewegung beschreibt. |
contents[].url | string | Für einen Frame-Eintrag | Öffentliche Bild-URL oder Base64-kodierte JPG- oder PNG-Daten. |
settings.resolution | string | Nein | Ausgabeauflösung gemäß der obigen Zeile für das ausgewählte Modell. Der Standardwert ist 720p. |
settings.duration | integer | Nein | Videolänge in Sekunden gemäß der obigen Zeile für das ausgewählte Modell. Der Standardwert ist 10 für kling-4.0 und 5 für die anderen Modelle. Senden Sie eine Ganzzahl, keine Zeichenfolge. |
settings.multi_shot | boolean | Nein | Nur für kling-3.0 ist der offizielle Standardwert true. Setzen Sie true für mehrere Einstellungen oder false für eine Einstellung und legen Sie den Wert explizit fest, wenn Sie dieses Feld verwenden. |
settings.audio | string | Nein | Setzen Sie für kling-3.0 oder kling-2.6 den Wert native für generiertes Audio oder off, wenn kein Audio generiert werden soll. Legen Sie den Wert explizit fest, wenn Sie dieses Feld verwenden. |
options.callback_url | string | Nein | Öffentliche URL, die Aktualisierungen der Aufgabe empfängt. |
options.external_task_id | string | Nein | Ihre Kennung, mit der Sie die Aufgabe Ihrer Anwendung zuordnen können. |
options.watermark_info | object | Nein | Wasserzeichenkonfiguration für die Ausgabe. |
kling-4.0 stellt keinen settings.audio-Schalter bereit. Seine Videos enthalten eine Audiospur; lassen Sie das Feld weg, statt einen Wert zu senden, den das Modell ignoriert.
Die folgende Anfrage animiert ein Quellbild als fünf Sekunden langes Video:
{
"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. Das OpenAPI-Codepanel stellt Shell-, Python- und JavaScript-Anfragen mit demselben Body bereit.
Video abrufen
Die Antwort auf die Erstellung hat folgende Struktur:{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}
data.id. Verwenden Sie Kling-Aufgabe abrufen mit dieser ID, bis die Aufgabe einen Endstatus erreicht. Lesen Sie die Video-URL aus dem outputs-Array der Aufgabe aus.Pfadparameter
Kling model ID. kling-4.0 accepts 3-30 second durations and middle_frame inputs. kling-3.0 supports 4k resolution. The 2.x models accept 5- or 10-second duration.
Verfügbare Optionen:
kling-4.0, kling-3.0-turbo, kling-3.0, kling-2.6, kling-2.5-turbo Body
application/json
Image-to-video request fields exposed by the CometAPI route. The model ID is a path parameter, not a body field.
Antwort
200 - application/json
The task was created. Use data.id to retrieve its status and video output.
Zuletzt geändert am 13. November 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"
}
}