The Kling 3.0 series models API is now fully available Learn More Get Started Overview Quick Start Changelog API Reference General Info Rate Limits Callback Schema Video Generation Models Video Omni Text to Video Image to Video Reference to Video Motion Control Multi-elements to video Extend Video Lip Sync Avatar Text to Audio Video to Audio Text to Speech Voice Clone Image Recognize Element Effects Effect Templates NEW Video Effects Image Generation Models Image Omni Image Generation Reference to Image Extend Image AI Multi-Shot Virtual Try-On Others Query user info Pricing Billing Info Prepaid Resource Packs Protocols Privacy Policy of API Service Terms of API Service API Service Level Agreement Multi-Elements Initialize Video for Editing POST /v1/videos/multi-elements/init-selection cURL Copy Collapse curl --request POST \ --url https://api-singapore.klingai.com/v1/videos/multi-elements/init-selection \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "video_id": "", "video_url": "https://v1-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/animals-output-5s.mp4" }' 200 Copy Collapse { "code": 0, // Error code; Specific definitions can be found in "Error Code" "message": "string", // Error message "request_id": "string", // Request ID, generated by the system, used for tracking requests and troubleshooting "data": { "status": 0, // Rejection code, non-zero indicates recognition failure "session_id": "id", // Session ID, generated during video initialization task, remains unchanged during editing operations, valid for 24 hours "final_unit_deduction": "string", // The deduction units of task "fps": 30.0, // Frame rate of parsed video, required when fetching selection preview video "original_duration": 1000, // Duration of parsed video, required when creating task "width": 720, // Width of parsed video, currently unused "height": 1280, // Height of parsed video, currently unused "total_frame": 300, // Total frame count of parsed video, required when creating task "normalized_video": "url" // URL of initialized video } 💡 Initialize the original video before using Multi-elements feature. When replacing or removing elements within the existing video, the relevant elements need to be marked in the video beforehand. Request Header Content-Type string Required Default to application/json Data Exchange Format Authorization string Required Authentication information, refer to API authentication Request Body video_id string Optional The ID of the video generated by the Kling AI Only videos generated within the last 30 days are supported Only supports videos with a duration of ≥2 seconds and ≤5 seconds, or ≥7 seconds and ≤10 seconds Related to the video_url parameter: both video_id and video_url cannot be empty at the same time, and cannot both have values at the same time video_url string Optional Get link for uploaded video Only .mp4/.mov formats are supported Only supports videos with a duration of ≥2 seconds and ≤5 seconds, or ≥7 seconds and ≤10 seconds Video resolution must be between 720px and 2160px (inclusive) in both width and height Only supports videos with frame rates of 24, 30, or 60 fps Related to the video_id parameter: both video_id and video_url cannot be empty at the same time, and cannot both have values at the same time Add Video Selection Area POST /v1/videos/multi-elements/add-selection cURL Copy Collapse curl --request POST \ --url https://api-singapore.klingai.com/v1/videos/multi-elements/add-selection \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "session_id": "847570360458960960", "frame_index": 0, "points": [ { "x": 0.7738498789346246, "y": 0.297142857142857 } ] }' 200 Copy Collapse { "code": 0, // Error code; Specific definitions can be found in "Error Code" "message": "string", // Error message "request_id": "string", // Request ID, generated by the system, used for tracking requests and troubleshooting "data": { "status": 0, // Rejection code, non-zero indicates recognition failure "session_id": "id", // Session ID, generated during video initialization task, remains unchanged during editing operations, valid for 24 hours "final_unit_deduction": "string", // The deduction units of task "res": { "frame_index": 0, "rle_mask_list": [{ "object_id": 0, "rle_mask": { "size": [720, 1280], "counts": "string" }, "png_mask": { "size": [720, 1280], "base64": "string" } }] } } } Request Header Content-Type string Required Default to application/json Data Exchange Format Authorization string Required Authentication information, refer to API authentication Request Body session_id string Required Session ID, generated during the video initialization task and remains unchanged during editing operations frame_index int Required Frame Number A maximum of 10 frames can be marked. That is, up to 10 frames can be used to define selection areas in the video Only supports marking 1 frame at a time points array Required Click Coordinates, represented by x and y Value range: [0, 1], expressed as percentages; [0, 1] represents the top-left corner of the frame Multiple points can be marked at once; up to 10 points can be marked on a single frame ▾ Hide child attributes x float Required X coordinate [0-1] y float Required Y coordinate [0-1] Sample Code Decoding Image Segmentation Result export type RLEObject = { size: [h: number, w: number] counts: string } type RLE = { h: number w: number m: number binaries: number[] } export function decode(rleObj: RLEObject) { const [h, w] = rleObj.size const R: RLE = { h, w, m: 0, binaries: [0] } rleFrString(R, rleObj.counts) const unitArray = new Uint8Array(h * w) rleDecode(R, unitArray) return unitArray } function rleDecode(R: RLE, M: Uint8Array) { let j let k let p = 0 let v = false for (j = 0; j < R.m; j++) { for (k = 0; k < R.binaries[j]; k++) { const x = Math.floor(p / R.h) const y = p % R.h M[y * R.w + x] = v === false ? 0 : 1 // Note: y * width + x indicates row-major (horizontal) layout. p++ } v = !v } } function rleFrString(R: RLE, s: string) { let m = 0 let p = 0 let k let x let more const binaries = [] while (s[p]) { x = 0 k = 0 more = 1 while (more) { const c = s.charCodeAt(p) - 48 x |= (c & 0x1f) << (5 * k) more = c & 0x20 p++ k++ if (!more && c & 0x10) { x |= -1 << (5 * k) } } if (m > 2) { x += binaries[m - 2] } binaries[m++] = x } R.m = m R.binaries = binaries } Rendering the Segmentation Mask Layer // height refers to the video height and width refers to the video width function drawMask(rleMask: string, height: number, width: number) { if (!canvasRef.value) return const ctx = canvasRef.value.getContext('2d') if (!ctx) return const decodeData = decode({ counts: rleMask, size: [height, width] }) const imageData = ctx.createImageData(width, height) for (let y = 0; y < height; y++) { for (let x = 0; x < width; x++) { const index = y * width + x if (decodeData[index]) { const imageIndex = index * 4 // Set pixel color: red, green, blue, alpha imageData.data[imageIndex] = 116 // red imageData.data[imageIndex + 1] = 255 // green imageData.data[imageIndex + 2] = 82 // blue imageData.data[imageIndex + 3] = 163 // alpha } } } ctx.putImageData(imageData, 0, 0) } Delete Video Selection Area POST /v1/videos/multi-elements/delete-selection cURL Copy Collapse curl --request POST \ --url https://api-singapore.klingai.com/v1/videos/multi-elements/delete-selection \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "session_id": "847570360458960960", "frame_index": 0, "points": [ { "x": 0.7738498789346246, "y": 0.297142857142857 } ] }' 200 Copy Collapse { "code": 0, // Error code; Specific definitions can be found in "Error Code" "message": "string", // Error message "request_id": "string", // Request ID, generated by the system, used for tracking requests and troubleshooting "data": { "status": 0, // Rejection code, non-zero indicates recognition failure "session_id": "id", // Session ID, generated during video initialization task, remains unchanged during editing operations, valid for 24 hours "final_unit_deduction": "string", // The deduction units of task "res": { "frame_index": 0, "rle_mask_list": [{ "object_id": 0, "rle_mask": { "size": [720, 1280], "counts": "string" }, "png_mask": { "size": [720, 1280], "base64": "string" } }] } } } Request Header Content-Type string Required Default to application/json Data Exchange Format Authorization string Required Authentication information, refer to API authentication Request Body session_id string Required Session ID, generated during the video initialization task and remains unchanged during editing operations frame_index int Required Frame Number points array Required Click Coordinates to delete, represented by x and y Value range: [0, 1], expressed as percentages; [0, 1] represents the top-left corner of the frame Multiple points can be provided at once Coordinates must exactly match those used when adding the video selection area ▾ Hide child attributes x float Required X coordinate [0-1] y float Required Y coordinate [0-1] Clear Video Selection POST /v1/videos/multi-elements/clear-selection cURL Copy Collapse curl --request POST \ --url https://api-singapore.klingai.com/v1/videos/multi-elements/clear-selection \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "session_id": "847570360458960960" }' 200 Copy Collapse { "code": 0, // Error code; Specific definitions can be found in "Error Code" "message": "string", // Error message "request_id": "string", // Request ID, generated by the system, used for tracking requests and troubleshooting "data": { "status": 0, // Rejection code, non-zero indicates recognition failure "session_id": "id" // Session ID, generated during video initialization task, remains unchanged during editing operations, valid for 24 hours "final_unit_deduction": "string", // The deduction units of task } } Request Header Content-Type string Required Default to application/json Data Exchange Format Authorization string Required Authentication information, refer to API authentication Request Body session_id string Required Session ID, generated during the video initialization task and remains unchanged during editing operations Preview Video with Selected Areas POST /v1/videos/multi-elements/preview-selection cURL Copy Collapse curl --request POST \ --url https://api-singapore.klingai.com/v1/videos/multi-elements/preview-selection \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "session_id": "847570360458960960" }' 200 Copy Collapse { "code": 0, // Error code; Specific definitions can be found in "Error Code" "message": "string", // Error message "request_id": "string", // Request ID, generated by the system, used for tracking requests and troubleshooting "data": { "status": 0, // Rejection code, non-zero indicates recognition failure "session_id": "id", // Session ID, generated during video initialization task, remains unchanged during editing operations, valid for 24 hours "final_unit_deduction": "string", // The deduction units of task "res": { "video": "url", // Video with mask "video_cover": "url", // Cover image of video with mask "tracking_output": "url" // Mask result for each frame in image segmentation results } } } Request Header Content-Type string Required Default to application/json Data Exchange Format Authorization string Required Authentication information, refer to API authentication Request Body session_id string Required Session ID, generated during the video initialization task and remains unchanged during editing operations Create Task POST /v1/videos/multi-elements cURL Copy Collapse curl --request POST \ --url https://api-singapore.klingai.com/v1/videos/multi-elements \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "model_name": "kling-v1-6", "session_id": "847570360458960960", "edit_mode": "removal", "image_list": [], "prompt": "Delete the chick from <<>>", "negative_prompt": "", "mode": "std", "duration": "5", "callback_url": "", "external_task_id": "" }' 200 Copy Collapse { "code": 0, // Error code; Specific definitions can be found in "Error Code" "message": "string", // Error message "request_id": "string", // Request ID, generated by the system, used for tracking requests and troubleshooting "data": { "task_id": "string", // Task ID, generated by the system "task_status": "string", // Task status, Enum values: submitted, processing, succeed, failed "task_info": { "external_task_id": "string" // User-defined task ID }, "created_at": 1722769557708, // Task creation time, Unix timestamp, unit: ms "updated_at": 1722769557708 // Task update time, Unix timestamp, unit: ms } } Request Header Content-Type string Required Default to application/json Data Exchange Format Authorization string Required Authentication information, refer to API authentication Request Body model_name string Optional Default to kling-v1-6 Model Name Enum values: kling-v1-6 session_id string Required Session ID, generated during the video initialization task and remains unchanged during editing operations edit_mode string Required Operation Type Enum values: addition swap removal addition: Add an element swap: Replace an element removal: Remove an element image_list array Optional Cropped Reference Images For adding video elements: This parameter is required; upload 1–2 images For editing (swapping) video elements: This parameter is required; upload 1 image only For deleting video elements: This parameter is not required Use key:value format as follows: "image_list":[ { "image":"image_url" }, { "image":"image_url" } ] The API does not perform cropping, please upload images with subjects already cropped Supports image input as either Base64-encoded string or URL (ensure the URL is publicly accessible) Important: When using Base64, do NOT add any prefix like data:image/png;base64,. Submit only the raw Base64 string. Correct Base64 format: iVBORw0KGgoAAAANSUhEUgAAAAUA... Incorrect Base64 format (with data: prefix): data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA... Supported image formats: .jpg / .jpeg / .png Image file size must not exceed 10MB. Image dimensions must be at least 300px. Aspect ratio must be between 1:2.5 and 2.5:1 ▾ Hide child attributes image string Required Image URL or Base64 string prompt string Required Positive Prompt Use the format <<>> to explicitly refer to a specific video or image, such as <<>> or <<>> To ensure optimal results, the prompt must include references to the video and image(s) required for the editing Must not exceed 2,500 characters 💡 Recommended Prompt Templates: Adding Elements: EN: Using the context of <<>>, seamlessly add [x] from <<>> ZH: 基于<<>>中的原始内容,以自然生动的方式,将<<>>中的【】,融入<<>>的【】 Replacing Elements: EN: swap [x] from <<>> for [x] from <<>> ZH: 使用<<>>中的【】,替换<<>>中的【】 Removing Elements: EN: Delete [x] from <<>> ZH: 删除<<>>中的【】 Note: [x] or 【】 are placeholders where you should fill in specific content. negative_prompt string Optional Negative Prompt Must not exceed 2,500 characters mode string Optional Default to std Video Generation Mode Enum values: std pro std: Standard mode, basic rendering, cost-effective pro: Professional mode, high-quality, enhanced rendering, better video output quality duration string Optional Default to 5 Video Duration (in seconds) Enum values: 5 10 Only 5-second and 10-second videos are supported To generate a 5-second video, the input video must be ≥2 seconds and ≤5 seconds To generate a 10-second video, the input video must be ≥7 seconds and ≤10 seconds watermark_info object Optional Whether to generate watermarked results simultaneously Defined by the enabled parameter, format: "watermark_info": { "enabled": boolean } true: generate watermarked result, false: do not generate Custom watermarks are not currently supported callback_url string Optional Callback URL for Task Result Notification. If configured, the server will actively send notifications when the task status changes For the message schema, refer to the Callback Protocol external_task_id string Optional Custom Task ID A user-defined task ID; it will not overwrite the system-generated task ID, but can be used to query the task Please ensure uniqueness of the task ID within a single user account Query Task (Single) GET /v1/videos/multi-elements/{id} cURL Copy Collapse curl --request GET \ --url https://api-singapore.klingai.com/v1/videos/multi-elements/{task_id} \ --header 'Authorization: Bearer ' 200 Copy Collapse { "code": 0, // Error code; Specific definitions can be found in "Error Code" "message": "string", // Error message "request_id": "string", // Request ID, generated by the system, used for tracking requests and troubleshooting "data": { "task_id": "string", // Task ID, generated by the system "task_status": "string", // Task status, Enum values: submitted, processing, succeed, failed "task_status_msg": "string", // Task status message, displays failure reason when task fails (e.g., triggered platform content moderation) "task_info": { // Task creation parameters "external_task_id": "string" // User-defined task ID }, "task_result": { "videos": [ { "id": "string", // Generated video ID, globally unique "session_id": "id", // Session ID, generated during video initialization task, remains unchanged during editing operations, valid for 24 hours "url": "string", // URL of generated video (Note: For security purposes, generated images/videos will be deleted after 30 days, please save them promptly) "watermark_url": "string", // Watermarked video download URL, anti-hotlinking format "duration": "string" // Total video duration, unit: s } ] }, "watermark_info": { "enabled": boolean }, "final_unit_deduction": "string", // Final unit deduction for the task "created_at": 1722769557708, // Task creation time, Unix timestamp, unit: ms "updated_at": 1722769557708 // Task update time, Unix timestamp, unit: ms } } Request Header Content-Type string Required Default to application/json Data Exchange Format Authorization string Required Authentication information, refer to API authentication Path Parameters task_id string Optional Task ID for Multi-Elements video editing Request path parameter, fill the value directly in the request path You can choose to query by external_task_id or task_id external_task_id string Optional Custom Task ID for Multi-Elements video editing The external_task_id filled in when creating the task. You can choose to query by external_task_id or task_id Query Task (List) GET /v1/videos/multi-elements cURL Copy Collapse curl --request GET \ --url 'https://api-singapore.klingai.com/v1/videos/multi-elements?pageNum=1&pageSize=30' \ --header 'Authorization: Bearer ' 200 Copy Collapse { "code": 0, // Error code; Specific definitions can be found in "Error Code" "message": "string", // Error message "request_id": "string", // Request ID, generated by the system, used for tracking requests and troubleshooting "data": [ { "task_id": "string", // Task ID, generated by the system "task_status": "string", // Task status, Enum values: submitted, processing, succeed, failed "task_status_msg": "string", // Task status message, displays failure reason when task fails (e.g., triggered platform content moderation) "task_info": { // Task creation parameters "external_task_id": "string" // User-defined task ID }, "task_result": { "videos": [ { "id": "string", // Generated video ID, globally unique "session_id": "id", // Session ID, generated during video initialization task, remains unchanged during editing operations, valid for 24 hours "url": "string", // URL of generated video (Note: For security purposes, generated images/videos will be deleted after 30 days, please save them promptly) "watermark_url": "string", // Watermarked video download URL, anti-hotlinking format "duration": "string" // Total video duration, unit: s } ] }, "watermark_info": { "enabled": boolean }, "final_unit_deduction": "string", // Final unit deduction for the task "created_at": 1722769557708, // Task creation time, Unix timestamp, unit: ms "updated_at": 1722769557708 // Task update time, Unix timestamp, unit: ms } ] } Request Header Content-Type string Required Default to application/json Data Exchange Format Authorization string Required Authentication information, refer to API authentication Query Parameters pageNum int Optional Default to 1 Page number Value range: [1, 1000] pageSize int Optional Default to 30 Number of items per page Value range: [1, 500] Previous chapter:Motion Control Next chapter:Extend Video Initialize Video for Editing Add Video Selection Area Delete Video Selection Area Clear Video Selection Preview Video with Selected Areas Create Task Query Task (Single) Query Task (List) The Kling 3.0 Series Models API is Now Fully Available – All in One, One for All! Models Available in This Release Kling 3.0 Motion Control, Kling Video 3.0, Kling Video 3.0 Omni, Kling Image 3.0, Kling Image 3.0 Omni Refer to Key Highlights of the Models 3.0 All-in-One: A unified model for multi-modal input and output. Most powerful consistency across the universe: Subject consistency (supports cameo, subject with voice control, i2v + subject) and text consistency. Narrative control at your fingertips: More freedom, precision, and control—up to 15 seconds long, video scene cuts, ultra-high-definition storyboards/images, custom seconds. Upgraded native audio-visual output: Supports multiple speakers and languages (with accents). Kling 3.0 Motion Control Consistent Facial Identity from any angle Complex Emotions faithfully reproduced High fidelity Restoration, Even with Face Occlusions Consistent Facial Clarity Across Dynamic Framing User Guide -> Kling Video 3.0 Compared to 2.6, expected improvements: Supports subject upload in I2V scenarios for enhanced consistency Significant improvement in multi-character referencing, especially for three-person scenarios Supports Japanese, Korean, and Spanish in addition to Chinese and English Capable of generating certain dialects and accents Better distinction and control over different types of audio (speech, sound effects, BGM) Improved text retention in I2V scenarios Supports scene transitions, with up to 6 shots and customizable storyboarding User Guide -> Kling Video 3.0 Omni Compared to O1, expected improvements: Native audio-visual synchronization Supports video subject creation Further improved consistency in reference-based tasks, especially for characters and products Combined capabilities of reference + storyboarding + audio-visual sync significantly enhance usability Supports scene transitions, with up to 6 shots Extended generation duration up to 15 seconds User Guide -> Kling Image 3.0 Highly consistent feature retention Precise response to detail modifications Accurate control over style and tone Rich imaginative capabilities User Guide -> Kling Image 3.0 Omni Enhanced narrative sense New storyboard image set generation, retaining reference image features with scene relevance Direct output of 2K/4K ultra-high-definition images Further improved detail consistency User Guide -> Thank you for your support and understanding! I Got It