Percorsi per modello
Crea un task Kling da immagine a video in base al modello
Crea un video Kling a partire da un’immagine di origine usando un percorso specifico per il modello, quindi recupera il video tramite l’ID del task.
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"
}
}Invia un’immagine di origine a
Quando usi un’immagine diversa, sostituisci l’URL dell’immagine con un URL pubblico o con i dati JPG/PNG codificati in Base64 dell’immagine sorgente. Invia questo corpo a
Salva
POST /image-to-video/{model} per creare un task video. Puoi aggiungere un prompt per descrivere il movimento. La risposta contiene un id da usare per recuperare il risultato.
Scegli un modello
Inserisci l’ID del modello nell’URL. Non aggiungere un campo model al corpo JSON.| ID modello | Risoluzione | Durata | Audio |
|---|---|---|---|
kling-4.0 | 720p, 1080p | Numero intero da 3 a 30 secondi | Ometti audio |
kling-3.0-turbo | 720p, 1080p | Numero intero da 3 a 15 secondi | Ometti audio |
kling-3.0 | 720p, 1080p, 4k | Numero intero da 3 a 15 secondi | native o off |
kling-2.6 | 720p, 1080p | 5 o 10 secondi | native o off; usa 1080p con native |
kling-2.5-turbo | 720p, 1080p | 5 o 10 secondi | Ometti audio |
kling-4.0 accetta first_frame, middle_frame e last_frame; includi un first_frame quando usi last_frame. kling-3.0-turbo accetta solo un first_frame. kling-2.5-turbo,
kling-3.0, e kling-2.6 supportano anche un last_frame; includi un
first_frame con esso. Per kling-2.5-turbo e kling-2.6, la
combinazione di primo e ultimo fotogramma richiede 1080p.
Parametri della richiesta
Inserisci ogni input incontents. Una voce prompt utilizza text; una voce relativa a un frame utilizza url. Per un’immagine, fornisci un URL accessibile pubblicamente o dati JPG o PNG codificati in Base64.
| Campo | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
Percorso model | stringa | Sì | ID del modello nell’URL. Scegli un ID dalla tabella precedente; non aggiungerlo al corpo della richiesta. |
contents | array | Sì | Voci di input. Includi un’immagine first_frame; aggiungi una voce prompt o un’immagine last_frame supportata dal modello quando necessario. |
contents[].type | stringa | Sì | prompt, first_frame, oppure last_frame. Includi un first_frame quando usi last_frame; il modello selezionato determina se last_frame è disponibile. |
contents[].text | stringa | Per una voce prompt | Testo che descrive il movimento. |
contents[].url | stringa | Per una voce relativa a un frame | URL pubblico dell’immagine o dati JPG o PNG codificati in Base64. |
settings.resolution | stringa | No | Risoluzione di output indicata nella riga del modello selezionato nella tabella precedente. Il valore predefinito è 720p. |
settings.duration | intero | No | Durata del video in secondi indicata nella riga del modello selezionato nella tabella precedente. Il valore predefinito è 10 per kling-4.0 e 5 per gli altri modelli. Invia un numero intero, non una stringa. |
settings.multi_shot | booleano | No | Solo per kling-3.0, il valore predefinito ufficiale è true. Imposta true per più riprese o false per una sola ripresa e specifica il valore esplicitamente quando usi questo campo. |
settings.audio | stringa | No | Per kling-3.0 o kling-2.6, imposta native per generare l’audio o off per non generarlo. Specifica il valore esplicitamente quando usi questo campo. |
options.callback_url | stringa | No | URL pubblico che riceve gli aggiornamenti dell’attività. |
options.external_task_id | stringa | No | Il tuo identificatore per associare l’attività alla tua applicazione. |
options.watermark_info | oggetto | No | Configurazione della filigrana per l’output. |
kling-4.0 non espone un’opzione settings.audio. I suoi video includono una traccia audio; ometti il campo anziché inviare un valore che il modello ignora.
La seguente richiesta anima un’immagine sorgente creando un video di cinque secondi:
{
"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 usando la tua chiave API CometAPI. Il pannello del codice OpenAPI fornisce richieste Shell, Python e JavaScript con lo stesso corpo.
Recuperare il video
La risposta alla richiesta di creazione ha questa struttura:{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}
data.id. Usa Ottieni un’attività Kling con quell’ID finché l’attività non raggiunge uno stato terminale. Leggi l’URL del video dall’array outputs dell’attività.Parametri del percorso
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.
Opzioni disponibili:
kling-4.0, kling-3.0-turbo, kling-3.0, kling-2.6, kling-2.5-turbo Corpo
application/json
Image-to-video request fields exposed by the CometAPI route. The model ID is a path parameter, not a body field.
Risposta
200 - application/json
The task was created. Use data.id to retrieve its status and video output.
Ultima modifica il 13 novembre 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"
}
}