Video / Kling

Kling 4.0 Video Generation

aslocalized example text.in use Kling 4.0 endpointlocalized example textKling 4.0 Video Generation API (endpoint).endpointtask and.

Overview

Kling 4.0 (can 4.0)videoModel: maximum 30 seconds, supported Text-to-Video, first frame / in / last frame video generation, and reference (Reference image, Reference video, Video Editing, subject and ).

and 3.0, 4.0 localized example textDuration15 seconds 30 seconds, supportedin, and inomni-video image, video, subject, asset.and can use Kling 4.0 Flash.

endpointPath, Request / field Kling (endpoint).complete,Base URL and API Key can, localized example text.

localized example textDescription
Resolution720p / 1080p (default), supported4k
Duration3-30 seconds, default 10 seconds
localized example text21:9 / 16:9 (default)/ 9:16 / 1:1, reference supportedadaptive
insupported ( first frame / in / last frame video generation)
subject /supported, only reference
localized example textDuration, Duration with no input video and Duration,「Billing」

Base URL: https://mm-internal-cn.leonecloud.com/kling


Authentication

with endpoint in Request in API Key:```
Authorization: Bearer {YOUR_API_KEY}


> API Key can, Not required AccessKey / SecretKey JWT.

---

## and| localized example text| localized example text|
|----|--------|
| Resolution | supported`4k`, will|
| localized example text| supported`settings.audio`, will ()|
| localized example text| supported`settings.multi_shot`, will|
| asset| http(s) URL, supported base64|
| subject / ID| `element_id`, `voice_id` return asset ID, number ID|
| subject /|, subject and|
| watermark | watermark:`options.watermark_info` can, with`watermark_url` |
| query results | return`billing` field, localized example text|
| localized example text| Callback Request,「Callback Notification」 |

---

## Quick Start

**Text-to-Video**
```bash

curl -X POST "https://mm-internal-cn.leonecloud.com/kling/text-to-video/kling-4.0" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "in,,,",
"settings": { "resolution": "1080p", "duration": 10, "aspect_ratio": "16:9" }
}'


**First/Last Frame to Video**
```bash

curl -X POST "https://mm-internal-cn.leonecloud.com/kling/image-to-video/kling-4.0" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{ "type": "prompt", "text": "," },
{ "type": "first_frame", "url": "https://example.com/start.jpg" },
{ "type": "last_frame", "url": "https://example.com/end.jpg" }
],
"settings": { "resolution": "1080p", "duration": 10 }
}'


**in video generation** (in in Status)```bash
curl -X POST "https://mm-internal-cn.leonecloud.com/kling/image-to-video/kling-4.0" \
 -H "Authorization: Bearer your_api_key_here" \
 -H "Content-Type: application/json" \
 -d '{
 "contents": [
 { "type": "prompt", "text": ", after" },
 { "type": "first_frame", "url": "https://example.com/stand.jpg" },
 { "type": "middle_frame", "url": "https://example.com/sit.jpg" },
 { "type": "last_frame", "url": "https://example.com/lookup.jpg" }
 ],
 "settings": { "resolution": "1080p", "duration": 15 }
 }'

Reference image-to-Video (reference )

curl -X POST "https://mm-internal-cn.leonecloud.com/kling/omni-video/kling-4.0" \
 -H "Authorization: Bearer your_api_key_here" \
 -H "Content-Type: application/json" \
 -d '{
 "contents": [
 { "type": "prompt", "text": "@image_1 in the@image_2 localized example text" },
 { "type": "refer_image", "url": "https://example.com/girl.png", "id": "image_1" },
 { "type": "refer_image", "url": "https://example.com/cafe.png", "id": "image_2" }
 ],
 "settings": { "resolution": "1080p", "duration": 10 },
 "options": { "external_task_id": "my-order-001" }
 }'

subject and

curl -X POST "https://mm-internal-cn.leonecloud.com/kling/omni-video/kling-4.0" \
 -H "Authorization: Bearer your_api_key_here" \
 -H "Content-Type: application/json" \
 -d '{
 "contents": [
 { "type": "prompt", "text": "@zhang,「will」" },
 { "type": "element", "element_id": "kel_xxxxxxxx", "id": "zhang" },
 { "type": "voice", "voice_id": "kvo_xxxxxxxx", "id": "voice_1" }
 ],
 "settings": { "resolution": "1080p", "duration": 10 }
 }'

Query Task

curl -X GET "https://mm-internal-cn.leonecloud.com/kling/tasks?task_ids=task_20261120182953_bx5gm0k5" \
 -H "Authorization: Bearer your_api_key_here"

Endpoints

MethodPath (Base URL)localized example text
POST/text-to-video/kling-4.0Text-to-Video
POST/image-to-video/kling-4.0first frame / in / last frame Video
POST/omni-video/kling-4.0reference (Reference image / Reference video / Video Editing / subject / )
GET/tasksQuery Task (Task ID or Task ID, supported )

subject and create, query, endpoint and Kling 3.0 Omni,Kling 3.0 Omni localized example text「subject」and「localized example text」.


1. Text-to-Video

POST /text-to-video/kling-4.0

Request Parameters

ParameterTypeRequiredDescription
promptstringYesPrompt
settingsobjectNooutput,
optionsobjectNo:Callback URL, Task ID

2. first frame / in / last frame video generation**POST** /image-to-video/kling-4.0

Request Parameters

ParameterTypeRequiredDescription
contentsarrayYesasset,
settingsobjectNooutput,
optionsobjectNolocalized example text

contents

typefieldDescription
prompttextPrompt, can (Image-to-Video when )
first_frameurlfirst frame image, up to 1 images
middle_frameurlin image, in Status
last_frameurllast frame image, up to 1 images, must when provide first frame

localized example text

  • must1 images image asset,prompt can
  • image ( first frame+ in+ last frame )up to 10 images
  • first frame, last frame up to 1 images; supported「onlyfirst frame」and「last frame」, supported only last frame
  • first frame,aspect_ratio ---### 3. referencePOST /omni-video/kling-4.0

endpoint when supported Reference image-to-Video, Reference videovideo generation, Video Editing, subject and, in Promptlocalized example text@id asset.

Request Parameters

ParameterTypeRequiredDescription
contentsarrayYesasset, must 1prompt, localized example text
settingsobjectNooutput,
optionsobjectNolocalized example text

contents

localized example texttype, must with 1prompt:

typefieldDescription
prompttextPrompt, Required.can use@id asset,@image_1, @zhang
first_frameurl, idfirst frame image
middle_frameurl, idin image
last_frameurl, idlast frame image, must when provide first frame
refer_imageurl, idReference image (Scenario,, etc. )
feature_videourl, idReference video ( reference,, etc. )
base_videourl, idvideo ( in video)
elementelement_id, idsubject,element_id as create subject endpoint return ID,id RequiredPrompt
voicevoice_id, id,voice_id as create endpoint return ID

id in Prompt, task, maximum 64 characters.localized example textelement andvoice localized example text.

localized example text

localized example textlocalized example text
image (first frame+ in+ last frame+ Reference image)10 images
Reference video (reference+ )5 localized example text
video (base_video)1 localized example text
subject (element)7, in videocharacter subject up to 3
(voice)3
image + video + subject+ localized example textand15 (prompt )

localized example text

  • supported「onlyfirst frame」and「last frame」, supported only last frame
  • withbase_video when first frame and last frame
  • with first frame with Reference video when,aspect_ratio If omittedlocalized example text16:9

asset Requirements

TypeRequirements
Imagejpg / jpeg / png, exceeds 50MB, width and height at least 300px, Aspect ratio 1:2.5 ~ 2.5:1
Videomp4 / mov, exceeds 200MB, width and height 700-4553px, exceeds 8294400, Aspect ratio 0.4~2, frame rate 24-60fps

settings

ParameterTypeRequireddefaultlocalized example textDescription
resolutionstringNo1080plocalized example text720p / 1080p.supported4k
durationintNo10localized example text3-30, seconds
aspect_ratiostringNo16:9, reference21:9 / 16:9 / 9:16 / 1:1, reference supportedadaptive.with first frame or Reference video when asset
first field will, will.audio andmulti_shot Model supported,.

options

ParameterTypeRequiredDescription
callback_urlstringNotaskcomplete after Callback URL, http(s), exceeds 512 characters
external_task_idstringNoTask ID,, exceeds 128 characters.can use query

Response Example

{
 "code": 0,
 "message": "SUCCEED",
 "request_id": "trace_20261120182953_j7qmlblmjupg",
 "data": {
 "id": "task_20261120182953_bx5gm0k5",
 "status": "submitted",
 "create_time": 1795170593000,
 "update_time": 1795170593000,
 "external_id": "my-order-001"
 }
}

Billing

Kling 4.0 localized example textDuration, Duration with no input video, input videoDuration, output videoDuration:localized example textDuration
no input Videooutput Duration
with input video, input Duration≤ output Durationoutput Duration× 2
with input video, input Duration> output Durationinput Duration+ output Duration

input videoreference video (feature_video, base_video)and videocharacter subject.Resolution and with no input video, Pricing.

when Duration, after Duration and.


4. Query Task

GET /tasks

Request Parameters (URL query)

ParameterRequiredDescription
task_idslocalized example textCreate Taskreturndata.id, localized example text, localized example text
external_task_idslocalized example textcreate whenexternal_task_id, localized example text, localized example text

Parameter, up to 50 task.task.

Response Parameters

ParameterTypeDescription
data[].idstringTask ID
data[].statusstringsubmitted /processing in /succeeded Success / failed Failure
data[].messagestringFailure(onlyFailure when )
data[].create_timeintCreated Time, Unix seconds
data[].update_timeintUpdated Time, Unix seconds
data[].external_idstringTask ID ( with )
data[].outputs[]arraygenerated result (onlySuccesswhen )
data[].outputs[].typestringlocalized example textvideo
data[].outputs[].urlstringvideolocalized example text
data[].outputs[].durationstringvideoDuration, seconds

Response Example

{
 "code": 0,
 "message": "SUCCEED",
 "request_id": "trace_20261120183142_0vogwknig0un",
 "data": [
 {
 "id": "task_20261120182953_bx5gm0k5",
 "status": "succeeded",
 "create_time": 1795170593000,
 "update_time": 1795170821000,
 "external_id": "my-order-001",
 "outputs": [
 { "type": "video", "url": "https://fc-gw-sh.oss-accelerate.aliyuncs.com/downloads/20261120/xxx.mp4", "duration": "10" }
 ]
 }
 ]
}

Callback Notification

Create Taskwhenoptions.callback_url, taskSuccessor Failure after will POST Request.

Headers

Content-Type: application/json
X-Funcloud-Event: task.completed
X-Funcloud-Timestamp: 2026-11-20T18:31:42+08:00
X-Funcloud-Signature: {localized example text}

Body:task, field and query endpointdata[], withcode / data localized example text.

{
 "id": "task_20261120182953_bx5gm0k5",
 "status": "succeeded",
 "create_time": 1795170593000,
 "update_time": 1795170821000,
 "external_id": "my-order-001",
 "outputs": [
 { "type": "video", "url": "https://fc-gw-sh.oss-accelerate.aliyuncs.com/downloads/20261120/xxx.mp4", "duration": "10" }
 ]
}

return HTTP 2xx as; not when in 5 seconds, 10 seconds after, 3.


Error Codes

ErrorHTTP Status Code, as{ "code": <localized example text>, "message": "...", "request_id": "..." }:

HTTP Status CodecodeDescription
4001201Parameter,message
4011000API Key invalid or missing
4031103no ( IP in )
4041203task / asset in, or Model not
4291101Insufficient balance
4291302Requestlocalized example text
5005000Internal server error
5035001, after

taskFailure (query results status=failed)Failure, will.


Best Practices

  • Pollinglocalized example text:First 30 seconds3 seconds, after 10 seconds.recommended
  • -when:1080p 10 secondsvideoUsually 3 ~ 6 minutes, video and Reference video task
  • -localized example text:input video task「input+ output」, input videoDuration height; reference whenrefer_image localized example textfeature_video
  • in:in in Status,「A B C」; when
  • -asset:assetid, in Prompt@id,
  • -subject:subject in (@Zhang and@ZhangSan), can
  • -Model:and Kling 4.0 Flash; 15 seconds / audio controlKling 3.0
  • etc.:localized example textexternal_task_id, ID will (400/1201), when after can query task booking
Updated 2026-11-20