跳转到主要内容
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
  }
}
使用此端点可根据 Prompt 创建一个 Kling 文本生成视频任务。它会启动一个异步作业,而不是立即返回已完成的视频。

第一个可用请求

  • 先发送一个简短的 Prompt
  • 仅在基础流程可用后,再添加 aspect_ratiodurationmode
  • 如果你希望使用推送交付而不是纯轮询,请设置 callback_url

任务流程

1

提交生成请求

通过此端点创建任务,并保存返回的 Kling task id。
2

轮询任务状态

通过单个查询检查进度,直到任务进入终态。
3

持久化结果

当 Kling 返回已完成资源的元数据后,如果你需要长期保留,请将结果迁移到你自己的存储中。
有关完整的参数矩阵和模型轨道详情,请参阅官方 Kling 文档。将本页中的请求和响应结构作为 CometAPI 包装层的参考。

授权

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

请求头

Content-Type
string

Must be application/json.

请求体

application/json
prompt
string
默认值:Hello
必填

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).

可用选项:
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.

响应

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