Skip to content

Kling Multi-Elements Video Editing

Edit videos using natural language, supporting adding, replacing, and removing elements in videos.

Workflow

Multi-elements video editing requires the following steps:

  1. Initialize Video - Upload the video to be edited
  2. Mark Selection (Optional) - Mark the video elements to be edited
  3. Preview Selection (Optional) - Preview the marked selection effect
  4. Create Task - Submit the video editing task

1. Initialize Video

Endpoint: POST /kling/v1/videos/multi-elements/init-selection

Description: Initialize the video to be edited and get a session ID for subsequent operations.

Authentication: Bearer Token

http
Authorization: Bearer YOUR_API_TOKEN

Request Parameters (Body)

FieldTypeRequiredDefaultDescription
video_idstringOptionalemptyVideo ID from history, only supports videos generated within 30 days. Choose either this or video_url.
video_urlstringOptional-Video URL. Only supports MP4 and MOV formats. Duration must be ≥2s and ≤5s, or ≥7s and ≤10s. Width/height must be between 720px and 2160px. Only supports 24, 30, or 60fps. Choose either this or video_id.

Response Parameters

FieldTypeDescription
codeintegerError code (0 indicates success)
messagestringError message
request_idstringRequest ID
data.statusintegerRejection code, non-zero means recognition failed
data.session_idstringSession ID, valid for 24 hours
data.fpsnumberParsed video frame rate
data.original_durationintegerParsed video duration
data.widthintegerParsed video width
data.heightintegerParsed video height
data.total_frameintegerParsed video total frames
data.normalized_videostringNormalized video URL

Response Example

json
{
  "code": 0,
  "message": "success",
  "request_id": "req_123456",
  "data": {
    "status": 0,
    "session_id": "session_abc123",
    "fps": 30.0,
    "original_duration": 5000,
    "width": 1280,
    "height": 720,
    "total_frame": 150,
    "normalized_video": "https://example.com/normalized_video.mp4"
  }
}

2. Add Selection

Endpoint: POST /kling/v1/videos/multi-elements/add-selection

Description: Mark the area to be edited in video frames.

Request Parameters (Body)

FieldTypeRequiredDefaultDescription
session_idstringRequired-Session ID
frame_indexintegerRequired-Frame number, max 10 marked frames supported
pointsarrayRequired-Point coordinate array
points[].xnumberRequired-X coordinate, range [0, 1]
points[].ynumberRequired-Y coordinate, range [0, 1], [0,0] represents top-left corner

Response Parameters

FieldTypeDescription
data.statusintegerRejection code
data.session_idstringSession ID
data.res.frame_indexintegerFrame number
data.res.rle_mask_listarrayRLE mask list containing image segmentation results

3. Delete Selection

Endpoint: POST /kling/v1/videos/multi-elements/delete-selection

Description: Delete marked selection points.

Request Parameters (Body)

FieldTypeRequiredDescription
session_idstringRequiredSession ID
frame_indexintegerRequiredFrame number
pointsarrayRequiredPoint coordinates to delete, must match exactly with add selection

4. Clear Selection

Endpoint: POST /kling/v1/videos/multi-elements/clear-selection

Description: Clear all marked selections.

Request Parameters (Body)

FieldTypeRequiredDescription
session_idstringRequiredSession ID

5. Preview Selection

Endpoint: POST /kling/v1/videos/multi-elements/preview-selection

Description: Preview the video effect with marked selections.

Request Parameters (Body)

FieldTypeRequiredDescription
session_idstringRequiredSession ID

Response Parameters

FieldTypeDescription
data.res.videostringVideo URL with mask
data.res.video_coverstringVideo cover URL with mask
data.res.tracking_outputstringMask result for each frame

6. Create Task

Endpoint: POST /kling/v1/videos/multi-elements

Description: Create a multi-elements video editing task.

Request Parameters (Body)

FieldTypeRequiredDefaultDescription
model_namestringOptionalkling-v1-6Model name
session_idstringRequired-Session ID
edit_modestringRequired-Edit mode: addition, swap, removal
image_listarrayOptionalemptyReference image list. Required for addition (1-2 images), required for swap (1 image), not needed for removal.
image_list[].imagestringRequired-Image Base64 or URL
promptstringRequired-Positive text prompt, max 2500 characters. Use <<<video_1>>> for video, <<<image_1>>> for image.
negative_promptstringOptionalemptyNegative text prompt, max 2500 characters
modestringOptionalstdGeneration mode: std, pro
durationstringOptional5Video duration: 5 or 10 seconds
callback_urlstringOptionalemptyCallback URL
external_task_idstringOptionalemptyCustom task ID

Addition:

Using the context of <<<video_1>>>, seamlessly add [subject] from <<<image_1>>> to [location]

Swap:

Swap [new element] from <<<image_1>>> for [original element] from <<<video_1>>>

Removal:

Delete [element description] from <<<video_1>>>

Response Parameters

FieldTypeDescription
data.task_idstringTask ID
data.task_statusstringTask status
data.session_idstringSession ID
data.created_atintegerTask creation time (ms)
data.updated_atintegerTask update time (ms)

7. Query Task

Endpoint: GET /kling/v1/videos/multi-elements/:task_id

Description: Query the status and result of a multi-elements video editing task.

Response Parameters

FieldTypeDescription
data.task_idstringTask ID
data.task_statusstringTask status
data.task_status_msgstringTask status message
data.task_result.videosarrayGenerated video list
data.task_result.videos[].idstringVideo ID
data.task_result.videos[].session_idstringSession ID
data.task_result.videos[].urlstringVideo URL
data.task_result.videos[].durationstringVideo duration (seconds)

企业合作联系:service@ezmodel.cloud