Chuyển đến nội dung chính
POST
/
kling
/
v1
/
videos
/
text2video
Text to Video
curl --request POST \
  --url https://api.cometapi.com/kling/v1/videos/text2video \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "A happy scene of a vacation on the beach."
}
'
{
  "code": 123,
  "message": "<string>",
  "request_id": "<string>",
  "data": {
    "task_id": "<string>",
    "task_status": "<string>",
    "created_at": 123,
    "updated_at": 123
  }
}
Sử dụng endpoint này để tạo một tác vụ text-to-video của Kling từ một prompt. Endpoint này khởi chạy một job async thay vì trả về ngay một video đã hoàn tất.

Yêu cầu đầu tiên hoạt động được

  • Trước tiên hãy gửi một prompt ngắn
  • Chỉ thêm aspect_ratio, duration, hoặc mode sau khi luồng cơ bản đã hoạt động
  • Đặt callback_url nếu bạn muốn nhận kết quả theo cơ chế push thay vì chỉ polling

Luồng tác vụ

1

Gửi yêu cầu tạo

Tạo tác vụ thông qua endpoint này và lưu Kling task id được trả về.
2

Polling trạng thái tác vụ

Kiểm tra tiến độ thông qua Individual Queries cho đến khi tác vụ đạt đến trạng thái kết thúc.
3

Lưu trữ kết quả

Khi Kling trả về metadata của asset đã hoàn tất, hãy chuyển kết quả vào hệ thống lưu trữ của riêng bạn nếu bạn cần lưu giữ lâu dài.
Để xem đầy đủ ma trận tham số và chi tiết về model-track, hãy tham khảo tài liệu Kling chính thức. Sử dụng cấu trúc request và response trên trang này làm tài liệu tham chiếu cho wrapper của CometAPI.

Ủy quyền

Authorization
string
header
bắt buộc

Bearer token authentication. Use your CometAPI key.

Tiêu đề

Content-Type
string

Must be application/json.

Nội dung

application/json
prompt
string
mặc định:Hello
bắt buộc

Text prompt describing the video to generate. Maximum 500 characters.

negative_prompt
string

Elements to exclude from the video. Maximum 200 characters.

aspect_ratio
string

Output aspect ratio (width:height). Options: 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3.

callback_url
string

Webhook URL to receive task status updates when the task completes.

model_name
string

Kling model variant to use. See the Models page for current options.

cfg_scale
number

Prompt adherence strength. Higher values follow the prompt more closely. Range: 0–1.

mode
enum<string>

Generation mode. std for standard (faster), pro for professional (higher quality).

Tùy chọn có sẵn:
std,
pro
duration
string

Output video length in seconds. Options: 5, 10.

camera_control
object

Camera motion preset or manual configuration. Omit for automatic camera movement.

external_task_id
string

Custom task id for your own tracking. Does not replace the system-generated task id but can be used to query tasks. Must be unique per user.

Phản hồi

200 - application/json

Successful Response

code
integer

Error code; specifically define the error code

message
string

error message

request_id
string

Request ID, system-generated, for tracking requests, troubleshooting issues

data
object