モデル別ルート
モデルを指定してKlingのテキストから動画を生成するタスクを作成
モデル固有のルートを使用してテキストプロンプト(Prompt)からKling動画を作成し、タスクIDで動画を取得します。
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"
}
}POST /text-to-video/{model} にプロンプト(Prompt)を送信して動画タスクを作成します。レスポンスには、結果の取得に使用する id が含まれます。
モデルを選択
URLにモデルIDを指定します。JSONボディにモデルフィールドを追加しないでください。| モデルID | 解像度 | 長さ | 音声 |
|---|---|---|---|
kling-4.0 | 720p, 1080p | 3秒から30秒までの整数 | 省略 audio |
kling-3.0-turbo | 720p, 1080p | 3秒から15秒までの整数 | 省略 audio |
kling-3.0 | 720p, 1080p, 4k | 3秒から15秒までの整数 | native または off |
kling-2.6 | 720p, 1080p | 5秒または10秒 | native または off。1080p は次と併用: native |
kling-2.5-turbo | 720p, 1080p | 5秒または10秒 | 省略 audio |
リクエストパラメータ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
パス model | 文字列 | はい | URL内のモデルID。上の表からIDを選択してください。リクエストボディには追加しないでください。 |
prompt | 文字列 | はい | 生成する動画の説明。 |
settings.resolution | 文字列 | いいえ | 上の表の選択したモデルの行に記載された出力解像度。デフォルトは 720p. |
settings.aspect_ratio | 文字列 | いいえ | 出力フレーム比率:21:9(kling-4.0 のみ)、16:9、9:16、または 1:1。デフォルトは 16:9. |
settings.duration | 整数 | いいえ | 上の表の選択したモデルの行に記載された動画の長さ(秒)。デフォルトは kling-4.0 では 10、それ以外のモデルでは 5 です。文字列ではなく整数を送信してください。 |
settings.multi_shot | ブール値 | いいえ | kling-3.0 の場合のみ、公式のデフォルト値は true です。複数のショットには true、単一のショットには false を設定してください。このフィールドを使用する場合は値を明示的に設定してください。 |
settings.audio | 文字列 | いいえ | kling-3.0 または kling-2.6 では、音声を生成する場合は native、生成しない場合は off を設定してください。このフィールドを使用する場合は値を明示的に設定してください。 |
options.callback_url | 文字列 | いいえ | タスクの更新を受け取る公開URL。 |
options.external_task_id | 文字列 | いいえ | タスクをアプリケーションと照合するための識別子。 |
options.watermark_info | オブジェクト | いいえ | 出力の透かし設定。 |
kling-4.0 では settings.audio の切り替え機能は提供されていません。動画には音声トラックが含まれるため、モデルが無視する値を送信するのではなく、このフィールドを省略してください。
次のリクエストは、kling-3.0-turbo を使用して5秒の動画を作成します。
{
"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 に送信します。OpenAPIのコードパネルには、同じボディを使用するShell、Python、JavaScriptのリクエストが用意されています。
動画を取得
作成時のレスポンスは次の形式です。{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}
data.id を保存します。次の Klingタスクを取得 を使用し、そのIDでタスクが終了ステータスに達するまで確認します。タスクの outputs 配列から動画のURLを読み取ります。パスパラメータ
ボディ
application/json
Text-to-video request fields exposed by the CometAPI route. The model ID is a path parameter, not a body field.
レスポンス
200 - application/json
The task was created. Use data.id to retrieve its status and video output.
最終更新日 2026年11月13日
⌘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"
}
}