Modellrouten
Einen Kling-model-route-Task abrufen
Rufen Sie den Status und die Videoausgabe eines Kling-model-route-Tasks anhand seiner Task-ID ab.
GET
/
tasks
cURL
task_id="<task_id>"
curl "https://api.cometapi.com/tasks?task_ids=${task_id}" \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import requests
task_id = "<task_id>"
response = requests.get(
"https://api.cometapi.com/tasks",
params={"task_ids": task_id},
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
)
response.raise_for_status()
payload = response.json()
task = payload.get("data", payload)
if isinstance(task, list):
task = task[0]
print(task["status"], task.get("outputs", []))
const taskId = "<task_id>";
const url = new URL("https://api.cometapi.com/tasks");
url.searchParams.set("task_ids", taskId);
const response = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const payload = await response.json();
const data = payload.data ?? payload;
const task = Array.isArray(data) ? data[0] : data;
console.log(task.status, task.outputs ?? []);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/tasks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/tasks"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cometapi.com/tasks")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/tasks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": [
{
"id": "<task_id>",
"status": "submitted"
}
]
}Verwenden Sie diesen Endpoint nach einer Kling-model-route-Erstellungsanfrage. Speichern Sie
Um einen einzelnen Task abzurufen, ersetzen Sie
Unmittelbar nach der Erstellung enthält die Antwort den übermittelten Task:
Speichern Sie das fertige Video in Ihrem eigenen Speicher, wenn Sie es über die Verfügbarkeit der zurückgegebenen URL hinaus behalten müssen.
data.id aus der Erstellungsantwort und übergeben Sie diese ID als task_ids.
Anfrageparameter
| Parameter | Erforderlich | Beschreibung |
|---|---|---|
task_ids | Ja | Task-ID, die von einer model-route-Erstellungsanfrage zurückgegeben wird, in data.id. |
<task_id> durch den Wert data.id aus der Erstellungsantwort:
task_id="<task_id>"
curl "https://api.cometapi.com/tasks?task_ids=${task_id}" \
-H "Authorization: Bearer $COMETAPI_KEY"
{
"code": 0,
"message": "SUCCEED",
"data": [
{
"id": "<task_id>",
"status": "submitted"
}
]
}
Ergebnis lesen
Lesen Sie den Task ausdata[0] und fragen Sie weiter ab, bis sein status einen Endzustand erreicht hat. Wenn der Status succeeded ist, lesen Sie die Video-URL aus dem Array outputs dieses Tasks. Einige beobachtete Comet-Kompatibilitätsantworten geben ein bloßes Task-Objekt zurück oder enthalten ein status der obersten Ebene; dies sind Kompatibilitätsformen, nicht die kanonische Antworthülle. Wenn data vorhanden ist, verwenden Sie data[0].status.
Ein abgeschlossener Task hat diese Antwortstruktur:
{
"code": 0,
"message": "SUCCEED",
"data": [
{
"id": "<task_id>",
"status": "succeeded",
"outputs": [
{
"type": "video",
"url": "https://media.example.com/video.mp4",
"duration": "5.041"
}
]
}
]
}
| Feld | Beschreibung |
|---|---|
id | Task-ID aus der Erstellungsantwort. |
status | Aktueller Task-Status. Fragen Sie weiter ab, bis er einen Endzustand erreicht. |
message | Task-Details, sofern verfügbar, zurückgegeben. |
outputs[].type | Ausgabemedientyp. Wählen Sie ein Element mit type: video. |
outputs[].url | Video-URL zum Herunterladen oder Speichern, wenn der Task erfolgreich ist. |
outputs[].duration | Videodauer in Sekunden, sofern zurückgegeben. |
Abfrageparameter
Antwort
200 - application/json
The task state and available outputs are returned in the data array.
Canonical task response for the CometAPI route. Read the selected task from data[0]; a bare task object is a compatibility form.
Zuletzt geändert am 25. September 2026
⌘I
cURL
task_id="<task_id>"
curl "https://api.cometapi.com/tasks?task_ids=${task_id}" \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import requests
task_id = "<task_id>"
response = requests.get(
"https://api.cometapi.com/tasks",
params={"task_ids": task_id},
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
)
response.raise_for_status()
payload = response.json()
task = payload.get("data", payload)
if isinstance(task, list):
task = task[0]
print(task["status"], task.get("outputs", []))
const taskId = "<task_id>";
const url = new URL("https://api.cometapi.com/tasks");
url.searchParams.set("task_ids", taskId);
const response = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const payload = await response.json();
const data = payload.data ?? payload;
const task = Array.isArray(data) ? data[0] : data;
console.log(task.status, task.outputs ?? []);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/tasks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/tasks"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cometapi.com/tasks")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/tasks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": [
{
"id": "<task_id>",
"status": "submitted"
}
]
}