Tuyến theo mô hình
Tạo video Kling Omni
Tạo tác vụ video Kling Omni với ID mô hình trong URL, sau đó truy xuất kết quả bằng ID tác vụ.
POST
/
omni-video
/
{model}
cURL
curl https://api.cometapi.com/omni-video/kling-3.0-omni \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}
JSONimport os
import requests
response = requests.post(
"https://api.cometapi.com/omni-video/kling-3.0-omni",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond.",
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": False,
"audio": "off",
},
},
)
response.raise_for_status()
result = response.json()
print(result["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/omni-video/kling-3.0-omni",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
console.log(result.data.id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/omni-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' => 'A paper boat drifts on a pond.'
]
]
]),
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/omni-video/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\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/omni-video/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/omni-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\": \"A paper boat drifts on a pond.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}Sử dụng
Đối với
Phản hồi trả về một
Sử dụng giá trị
POST /omni-video/{model} để tạo tác vụ video Kling Omni bất đồng bộ. Đặt ID mô hình trong URL và cung cấp dữ liệu đầu vào trong contents.
Chọn mô hình
kling-4.0:720phoặc1080p; 3-30 giây; không có trườngaudio. Hỗ trợ tỷ lệ khung hìnhadaptivebên cạnh các tỷ lệ cố định và chấp nhận nội dungmiddle_frame.kling-3.0-omni:720p,1080p, hoặc4k; 3-15 giây; âm thanhnative,originalhoặcoff.kling-o1:720phoặc1080p; 3-10 giây; âm thanhoriginalhoặcoff.
kling-3.0-omni. Để tạo video không có âm thanh, đặt settings.audio thành off.
Tham số yêu cầu
| Trường | Bắt buộc | Mô tả |
|---|---|---|
Đường dẫn model | Có | ID mô hình trong URL. Chọn một ID từ danh sách ở trên; không thêm ID này vào phần thân yêu cầu. |
contents | Có | Mảng đầu vào video không được để trống. Đối với yêu cầu chỉ có văn bản, hãy thêm một mục prompt. |
contents[].type | Có | prompt, first_frame, middle_frame, last_frame, refer_image, feature_video, hoặc base_video. middle_frame có sẵn với kling-4.0. Một last_frame cần có first_frame. |
contents[].text | Đối với mục prompt | Văn bản mô tả video. |
contents[].url | Đối với các mục hình ảnh hoặc video | URL hình ảnh hoặc dữ liệu hình ảnh Base64; các mục video sử dụng URL video công khai. |
settings.resolution | Không | Độ phân giải đầu ra. Nếu bỏ qua, yêu cầu sẽ sử dụng 720p. Các giá trị có thể dùng phụ thuộc vào model. |
settings.aspect_ratio | Không | Tỷ lệ khung hình: adaptive (chỉ dành cho kling-4.0), 16:9, 9:16 hoặc 1:1. Giá trị mặc định là 16:9. |
settings.duration | Không | Thời lượng video tính bằng giây nguyên. Giá trị mặc định là 10 đối với kling-4.0 và 5 đối với các mô hình khác. Sử dụng thời lượng nằm trong phạm vi của mô hình đã chọn. Gửi một số nguyên, không phải chuỗi. |
settings.multi_shot | Không | Đối với kling-3.0-omni, đặt true để tạo nhiều cảnh quay hoặc false để tạo một cảnh quay liên tục. Không đưa trường này vào yêu cầu đối với kling-o1. |
settings.audio | Không | Đặt native, original hoặc off tùy theo mô hình và đầu vào đã chọn. Không được hỗ trợ bởi kling-4.0. |
options.callback_url | Không | URL HTTPS nhận các lệnh gọi lại về trạng thái tác vụ. |
options.external_task_id | Không | Mã định danh tác vụ của riêng bạn để đối chiếu; hãy giữ lại data.id được trả về để truy vấn. |
options.watermark_info.enabled | Không | Đặt thành true để yêu cầu thêm hình mờ. |
kling-4.0, chỉ được phép có tối đa một mục nội dung base_video. Đối với kling-3.0-omni, đầu vào feature_video yêu cầu settings.multi_shot: true và settings.audio: off. Đầu vào base_video yêu cầu settings.multi_shot: false và không thể sử dụng settings.audio: native. Không kết hợp base_video với khung hình đầu hoặc cuối.
Giá trị mặc định chính thức của kling-3.0-omni là multi_shot: true; hãy đặt trường này một cách tường minh khi cần xác định chế độ cảnh quay. Đối với kling-o1, Prompt có thể chứa tối đa 2500 ký tự. Nếu yêu cầu chỉ chứa một first_frame và không có hình ảnh hoặc video tham chiếu nào khác, hãy sử dụng thời lượng 5 hoặc 10 giây.
Để tạo video dài năm giây chỉ từ văn bản, hãy gửi phần thân yêu cầu này đến POST /omni-video/kling-3.0-omni:
{
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}
id cho tác vụ bất đồng bộ:
{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}
data.id với Lấy tác vụ Kling cho đến khi tác vụ hoàn tất. Đọc URL video đã hoàn thành từ mảng outputs của tác vụ. Lưu video vào hệ thống lưu trữ của bạn nếu cần quyền truy cập lâu dài.
Bảng OpenAPI chứa các yêu cầu Shell, Python và JavaScript tương ứng. Để xem thêm các tổ hợp đầu vào, hãy tham khảo tài liệu tham chiếu API video Kling 3.0 Omni hoặc tài liệu tham chiếu API video Kling O1 Omni.Tham số đường dẫn
Nội dung
application/json
Omni video request fields exposed by the CometAPI route. The model ID is a path parameter, not a body field.
Phản hồi
200 - application/json
Task created. Store data.id for a GET /tasks query.
Lần sửa đổi cuối 13 tháng 11, 2026
⌘I
cURL
curl https://api.cometapi.com/omni-video/kling-3.0-omni \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}
JSONimport os
import requests
response = requests.post(
"https://api.cometapi.com/omni-video/kling-3.0-omni",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond.",
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": False,
"audio": "off",
},
},
)
response.raise_for_status()
result = response.json()
print(result["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/omni-video/kling-3.0-omni",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
console.log(result.data.id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/omni-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' => 'A paper boat drifts on a pond.'
]
]
]),
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/omni-video/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\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/omni-video/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/omni-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\": \"A paper boat drifts on a pond.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}