Skip to main content
POST
cURL
使用此端點可透過 Kling 根據文字 Prompt 產生一段短音訊片段。

呼叫前準備

  • 保持 prompt 簡潔明確
  • 先將 duration 設定在 3 到 10 秒之間
  • callback_urlexternal_task_id 視為可選的整合輔助欄位,而非核心需求

任務流程

1

提交音訊任務

送出文字 Prompt 與時長,然後儲存回傳的任務 id。
2

輪詢任務

使用 Kling 音訊查詢路徑,持續透過取得 Kling 任務查詢,直到任務進入終止狀態。
3

儲存音訊輸出

如果你需要在供應商交付視窗之外保留最終音訊資產,請將其持久化儲存。
如需完整的參數參考,請參閱官方 Kling 文件

授權

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

主體

application/json
prompt
string
必填

Text prompt describing the audio to generate. Max 200 characters.

duration
integer
必填

Duration of the generated audio in seconds. Range: 3.0–10.0, supports one decimal place.

external_task_id
string

Optional user-defined task ID for your own tracking. Does not replace the system-generated task ID. Must be unique per account.

callback_url
string

Webhook URL for task status notifications. The server sends a callback when the task status changes.

回應

200 - application/json

Task accepted.

code
integer
必填

Error code; specific error code definition

message
string
必填

Error message

data
object
必填