跳轉到主要內容
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