跳轉到主要內容
POST
/
kling
/
v1
/
videos
/
avatar
/
image2video
Create a Kling avatar task
curl --request POST \
  --url https://api.cometapi.com/kling/v1/videos/avatar/image2video \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "image": "example"
}
'
{
  "code": 123,
  "message": "<string>",
  "data": {
    "task_id": "<string>",
    "task_status": "<string>",
    "created_at": 123,
    "updated_at": 123,
    "task_info": {}
  }
}
使用此端點可透過一張來源圖片加上一個音訊來源,建立會說話的虛擬人像短片。

呼叫前準備

  • 提供一個虛擬人像 image,可使用公開 URL 或原始 base64 字串
  • audio_idsound_file 二擇一,且只能傳送其中一個
  • 第一個請求請保持簡單:一張人臉圖片、一段音訊片段,以及一段可選的簡短 prompt
  • 除非你明確需要更高品質的路徑,否則請先使用 mode: std

音訊來源規則

  • 如果你已透過 Kling TTS 路徑產生語音,audio_id 是最簡單的方式
  • 如果你已經有自己的 MP3、WAV、M4A 或 AAC 資源,可使用 sound_file
  • 文件指出虛擬人像音訊長度可為 2 到 60 秒

任務流程

1

建立虛擬人像任務

提交圖片與一個音訊來源,然後儲存回傳的 task id。
2

輪詢任務

持續使用 單筆查詢 直到任務進入最終狀態。
3

儲存完成結果

如果你需要在供應商交付 URL 之外保留結果,請將最終資產複製到你自己的儲存空間中。
完整參數參考請見官方 Kling Avatar 文件

授權

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

標頭

Content-Type
string

Optional content type header.

主體

application/json
image
string
預設值:example
必填

Avatar reference image. Accepts an image URL or raw Base64 string (no data: prefix). Supported formats: JPG, JPEG, PNG. Max file size 10 MB. Minimum dimension 300 px on each side; aspect ratio between 1:2.5 and 2.5:1.

audio_id
string
必填

Audio ID returned by the Kling TTS API. Only audio clips between 2 and 60 seconds generated within the last 30 days are accepted. Mutually exclusive with sound_file — exactly one must be provided.

sound_file
string

Audio file as a URL or Base64 string. Accepted formats: MP3, WAV, M4A, AAC. Max 5 MB, duration 2–60 seconds. Mutually exclusive with audio_id — exactly one must be provided.

prompt
string

Text prompt to guide avatar actions, emotions, and camera movements. Max 2500 characters.

mode
string

Generation mode. std (standard, faster and more cost-effective) or pro (professional, higher quality output).

callback_url
string

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

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.

回應

200 - application/json

Task accepted.

code
integer
必填
message
string
必填
data
object
必填