Skip to main content
POST
cURL
使用此端點可將一張來源圖片製作成動畫並生成 Kling 影片。

呼叫前準備

  • 提供一個公開圖片 URL 或一個 base64 圖片字串
  • 使用符合 Kling 像素要求的圖片;過小的縮圖會被生成任務拒絕
  • 先從預設的 kling-v2-6 範例開始,當你需要不同模型路線時,再從 OpenAPI enum 中選擇其他 model_name
  • 保持第一次請求簡單:一張輸入圖片、一個 prompt、無尾幀、無動作遮罩
  • 當你需要可控的局部動作時,使用 dynamic_masks 作為由遮罩與軌跡物件組成的陣列
  • 對於支援生成聲音的模型路線,第一個請求可使用 sound: off 來實現可重現且無音訊的結果

模型命名

在此端點上請使用一般的 Kling 影片 model ID。Omni model ID 請保留給 Omni Video

任務流程

1

提交圖生影片請求

建立任務並儲存回傳的 Kling task_id
2

輪詢任務

接著使用 取得 Kling 任務 持續追蹤任務狀態,直到輸出準備完成。
3

儲存結果

如果你需要在供應商交付 URL 的保留期限之外繼續保存資產,請持久化儲存已完成的成品。
完整參數參考請見官方 Kling 文件

授權

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

主體

application/json
image
string
必填

Source image URL or base64 image string. Use an image that meets Kling pixel requirements; very small thumbnails are rejected. For base64 input, send the encoded image string as the field value.

prompt
string

Text prompt describing the desired motion. Maximum 500 characters.

negative_prompt
string

Elements to exclude from the video. Maximum 200 characters.

callback_url
string

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

mode
enum<string>
預設值:std

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

可用選項:
std,
pro
model_name
enum<string>
預設值:kling-v1

Model ID for this image-to-video request. Use kling-v3 for new requests. Use Omni model IDs only with the Omni Video endpoint.

可用選項:
kling-v1,
kling-v1-5,
kling-v1-6,
kling-v2-master,
kling-v2-1,
kling-v2-1-master,
kling-v2-5-turbo,
kling-v2-6,
kling-v3
image_tail
string

Tail-frame reference image as a Base64 string or public URL. Same format requirements as image. Controls the last frame of the generated video.

cfg_scale
number

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

duration
string
預設值:5

Output video length in seconds. Use 5 or 10; omit to use 5.

static_mask
string

Static brush mask image as a Base64 string or public URL. White areas are frozen in place during video generation. Must match the aspect ratio and resolution of the input image.

dynamic_masks
object[]

Optional motion masks. Each entry contains a mask image and an ordered trajectory list.

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.

sound
enum<string>

Optional generated-audio switch for models that support video sound. Use on or off, or omit the field for the model default.

可用選項:
on,
off

回應

200 - application/json

Task accepted.

code
integer
必填

Error code; specifically define the error code

message
string
必填

error message

data
object
必填