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 text | Description |
|---|---|
| Resolution | 720p / 1080p (default), supported4k |
| Duration | 3-30 seconds, default 10 seconds |
| localized example text | 21:9 / 16:9 (default)/ 9:16 / 1:1, reference supportedadaptive |
| in | supported ( first frame / in / last frame video generation) |
| subject / | supported, only reference |
| localized example text | Duration, 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**
```bashcurl -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**
```bashcurl -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
| Method | Path (Base URL) | localized example text |
|---|---|---|
| POST | /text-to-video/kling-4.0 | Text-to-Video |
| POST | /image-to-video/kling-4.0 | first frame / in / last frame Video |
| POST | /omni-video/kling-4.0 | reference (Reference image / Reference video / Video Editing / subject / ) |
| GET | /tasks | Query 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | Prompt |
| settings | object | No | output, |
| options | object | No | :Callback URL, Task ID |
2. first frame / in / last frame video generation**POST** /image-to-video/kling-4.0
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| contents | array | Yes | asset, |
| settings | object | No | output, |
| options | object | No | localized example text |
contents
| type | field | Description |
|---|---|---|
prompt | text | Prompt, can (Image-to-Video when ) |
first_frame | url | first frame image, up to 1 images |
middle_frame | url | in image, in Status |
last_frame | url | last frame image, up to 1 images, must when provide first frame |
localized example text
- must1 images image asset,
promptcan - 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| contents | array | Yes | asset, must 1prompt, localized example text |
| settings | object | No | output, |
| options | object | No | localized example text |
contents
localized example texttype, must with 1prompt:
| type | field | Description |
|---|---|---|
prompt | text | Prompt, Required.can use@id asset,@image_1, @zhang |
first_frame | url, id | first frame image |
middle_frame | url, id | in image |
last_frame | url, id | last frame image, must when provide first frame |
refer_image | url, id | Reference image (Scenario,, etc. ) |
feature_video | url, id | Reference video ( reference,, etc. ) |
base_video | url, id | video ( in video) |
element | element_id, id | subject,element_id as create subject endpoint return ID,id RequiredPrompt |
voice | voice_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 text | localized 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 textand | 15 (prompt ) |
localized example text
- supported「onlyfirst frame」and「last frame」, supported only last frame
- with
base_videowhen first frame and last frame - with first frame with Reference video when,
aspect_ratioIf omittedlocalized example text16:9
asset Requirements
| Type | Requirements |
|---|---|
| Image | jpg / jpeg / png, exceeds 50MB, width and height at least 300px, Aspect ratio 1:2.5 ~ 2.5:1 |
| Video | mp4 / mov, exceeds 200MB, width and height 700-4553px, exceeds 8294400, Aspect ratio 0.4~2, frame rate 24-60fps |
settings
| Parameter | Type | Required | default | localized example text | Description |
|---|---|---|---|---|---|
| resolution | string | No | 1080p | localized example text | 720p / 1080p.supported4k |
| duration | int | No | 10 | localized example text | 3-30, seconds |
| aspect_ratio | string | No | 16:9 | , reference | 21:9 / 16:9 / 9:16 / 1:1, reference supportedadaptive.with first frame or Reference video when asset |
first field will, will.audioandmulti_shotModel supported,.
options
| Parameter | Type | Required | Description |
|---|---|---|---|
| callback_url | string | No | taskcomplete after Callback URL, http(s), exceeds 512 characters |
| external_task_id | string | No | Task 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 text | Duration |
|---|---|---|
| no input Video | output Duration | |
| with input video, input Duration≤ output Duration | output Duration× 2 | |
| with input video, input Duration> output Duration | input 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)
| Parameter | Required | Description |
|---|---|---|
| task_ids | localized example text | Create Taskreturndata.id, localized example text, localized example text |
| external_task_ids | localized example text | create whenexternal_task_id, localized example text, localized example text |
Parameter, up to 50 task.task.
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| data[].id | string | Task ID |
| data[].status | string | submitted /processing in /succeeded Success / failed Failure |
| data[].message | string | Failure(onlyFailure when ) |
| data[].create_time | int | Created Time, Unix seconds |
| data[].update_time | int | Updated Time, Unix seconds |
| data[].external_id | string | Task ID ( with ) |
| data[].outputs[] | array | generated result (onlySuccesswhen ) |
| data[].outputs[].type | string | localized example textvideo |
| data[].outputs[].url | string | videolocalized example text |
| data[].outputs[].duration | string | videoDuration, 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 Code | code | Description |
|---|---|---|
| 400 | 1201 | Parameter,message |
| 401 | 1000 | API Key invalid or missing |
| 403 | 1103 | no ( IP in ) |
| 404 | 1203 | task / asset in, or Model not |
| 429 | 1101 | Insufficient balance |
| 429 | 1302 | Requestlocalized example text |
| 500 | 5000 | Internal server error |
| 503 | 5001 | , 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 when
refer_imagelocalized example textfeature_video - in:in in Status,「A B C」; when
- -asset:asset
id, in Prompt@id, - -subject:subject in (
@Zhangand@ZhangSan), can - -Model:and Kling 4.0 Flash; 15 seconds / audio controlKling 3.0
- etc.:localized example text
external_task_id, ID will (400/1201), when after can query task booking