Kling 4.0 Flash API documentation
Integrate Kling 4.0 Flash with your VezAPI key. The operations below share the same authentication and account balance.
https://api.vezapi.comSend Authorization: Bearer YOUR_VEZAPI_KEY. Use a unique Idempotency-Key for each submission; reuse it only when checking the same request.
Kling 4.0 Flash Keyframe To Video
/api/v1/jobs/createTaskModel IDs: kling-4.0/flash-keyframe-to-video
| Parameter | Type | Description & constraints |
|---|---|---|
modelrequired | string | The name of the model used to generate the task. This field is required. - This endpoint requires the `kling-4.0/flash-keyframe-to-video` model Values: Default: |
callBackUrloptional | string | The URL to receive generation task completion updates. Optional but recommended for production use. - System will POST task status and results to this URL when generation completes - Callback includes generated content URLs and task information - Your callback endpoint should accept POST requests with JSON payload containing results - Alternatively, use the Get Task Details endpoint to poll task status - To ensure callback security, see [Webhook Verification Guide](/common-api/webhook-verification) for signature verification implementation |
inputrequired | object | Input parameters for the generation task. |
input.promptrequired | string | Video description. Required. Maximum 8000 characters. When `first_frame_url` is provided, mention it as `@first_frame`. Middle frames and a last frame are not supported on Kling 4.0 Flash — sending `keyframes` or `last_frame` is rejected.
|
input.durationoptional | integer | Output video duration in seconds. Integer from 3 to 20. Default: `5`. Default:
|
input.resolutionoptional | string | Output resolution. Kling 4.0 Flash only supports `720p`. Default: `720p`. Values: Default: |
input.aspect_ratiooptional | string | Output aspect ratio. `16:9`, `9:16`, `1:1`, or `21:9`. There is no `auto`. Only used when `first_frame_url` is omitted (text-to-video); default `16:9`. When a first frame is provided, the output follows that image's aspect ratio. Values: |
input.first_frame_urloptional | string | Optional first-frame image URL. Mention it in the prompt as `@first_frame`. If omitted, the request is plain text-to-video. Middle frames (`keyframes`) and a last frame (`last_frame`) are not supported. |
Request example
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
-H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
-H 'Idempotency-Key: your-unique-request-id' \
-H 'Content-Type: application/json' \
-d '{
"model": "kling-4.0/flash-keyframe-to-video",
"input": {
"prompt": "Animate the supplied image as one continuous 10-second shot. Keep the camera fixed to the opposite bench as the gondola ascends. Preserve the skier’s face, the goggles on her helmet, and the embroidered “KIE AI” patch.\nREFERENCES: @first_frame is the exact opening frame.",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9"
}
}'Responses and errors
HTTP 200
Request Successful
| Parameter | Type | Description & constraints |
|---|---|---|
codeoptional | integer | Response status code - **200**: Success - Request has been processed successfully - **401**: Unauthorized - Authentication credentials are missing or invalid - **402**: Insufficient Credits - Account does not have enough credits to perform the operation - **404**: Not Found - The requested resource or endpoint does not exist - **422**: Validation Error - The request parameters failed validation checks - **429**: Rate Limited - Request limit has been exceeded for this resource - **433**: Request Limit - Sub-key Usage Exceeds Limit - **455**: Service Unavailable - System is currently undergoing maintenance - **500**: Server Error - An unexpected error occurred while processing the request - **501**: Generation Failed - Content generation task failed - **505**: Feature Disabled - The requested feature is currently disabled Values: |
msgoptional | string | Response message, error description when failed |
datarequired | object | |
data.taskIdrequired | string | Task ID, can be used with Get Task Details endpoint to query task status |
Kling 4.0 Flash Reference To Video
/api/v1/jobs/createTaskModel IDs: kling-4.0/flash-reference-to-video
| Parameter | Type | Description & constraints |
|---|---|---|
modelrequired | string | The name of the model used to generate the task. This field is required. - This endpoint requires the `kling-4.0/flash-reference-to-video` model Values: Default: |
callBackUrloptional | string | The URL to receive generation task completion updates. Optional but recommended for production use. - System will POST task status and results to this URL when generation completes - Callback includes generated content URLs and task information - Your callback endpoint should accept POST requests with JSON payload containing results - Alternatively, use the Get Task Details endpoint to poll task status - To ensure callback security, see [Webhook Verification Guide](/common-api/webhook-verification) for signature verification implementation |
inputrequired | object | Input parameters for the generation task. |
input.promptrequired | string | Video description. Required. Maximum 8000 characters. Use `@` to mention assets uploaded in this request: - `@image_1`, `@image_2`, … map to `image_urls` in order (1-based) - `@video_1`, `@video_2`, … map to `video_urls` - `@name` maps to the `name` of an item in `elements` Every `@` mention must match an asset included in this request, otherwise the request is rejected. Mentions use longest-match against declared names. If the matched name ends with a letter, digit, or underscore, the next character cannot be a letter, digit, or underscore.
|
input.durationoptional | integer | Output video duration in seconds. Integer from 3 to 20. Default: `5`. Default:
|
input.resolutionoptional | string | Output resolution. Kling 4.0 Flash only supports `720p`. Default: `720p`. Values: Default: |
input.aspect_ratiooptional | string | Output aspect ratio. Optional. - If omitted and any reference asset is provided, the model uses `auto` - If omitted and no reference asset is provided, the model uses `16:9` Values: |
input.image_urlsoptional | array | Reference images, up to 10 publicly accessible URLs. Mention them in the prompt as `@image_1`, `@image_2`, … in array order. Default:
|
input.video_urlsoptional | array | Reference videos, up to 5 publicly accessible URLs. Mention them in the prompt as `@video_1`, `@video_2`, …. Reference videos plus video subjects in `elements` cannot exceed 5 in total. Combined duration of all reference videos and video elements must be 2–20 seconds; if it is outside that range the completion callback returns a failure. Default:
|
input.keep_original_soundoptional | boolean | Whether to keep the original audio of the reference videos. Only takes effect when `video_urls` is provided. Default: `false`. If no reference video is provided, native audio is always generated. Default: |
input.elementsoptional | array | Subjects used only for this task. Up to 7 items, of which at most 3 can be video subjects. Mention them in the prompt as `@name`. `image_urls`, `video_urls`, and `elements` together cannot exceed 15 items. Standalone `voices` is not supported on Flash. Default:
|
input.elements[].namerequired | string | The name used in the prompt as `@Hero`. 1–20 characters; Chinese, letters, digits, and underscore only. Must be unique across `elements` (case-insensitive). Reserved names (case-insensitive, N is a number) cannot be used: `image_N`, `video_N`, `keyframe_N`, `object_N`, `audio_N`, `first_frame`, `last_frame`. |
input.elements[].image_urlsoptional | array | 2–4 publicly accessible image URLs for an image subject. Cannot be used together with `video_url`. The first image is the primary view (front face or main angle); the rest are supporting views. Required when `type` is `image` or omitted.
|
input.elements[].video_urloptional | string | Character video URL for a video subject. Cannot be used together with `image_urls`. One video, 3–8 seconds, a single continuous shot (no cuts), shortest side at least 700 pixels. Required when `type` is `video`. |
input.elements[].tagoptional | string | Subject category. Optional for image subjects — if omitted, it is inferred from the primary image. Video subjects are always `character`; any other value is rejected. Values: |
input.elements[].descriptionoptional | string | Optional subject description. Maximum 100 characters.
|
input.elements[].voice_urloptional | string | Optional reference audio bound to this subject. It cannot be mentioned with `@` on its own. Only character subjects can bind audio: for image subjects `tag` must be `character` or omitted; for video subjects, if omitted the video's original speech is used by default. Standalone `voices` is not supported on Kling 4.0 Flash. |
input.elements[].typeoptional | string | Subject type. Optional, default `image`. - `image`: use `image_urls` (2–4 images of the same subject; first is the primary view). Do not send `video_url`. - `video`: use `video_url` (one 3–8 second single-shot character video). Do not send `image_urls`. Video subjects are always `character`. Values: Default: |
Request example
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
-H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
-H 'Idempotency-Key: your-unique-request-id' \
-H 'Content-Type: application/json' \
-d '{
"model": "kling-4.0/flash-reference-to-video",
"input": {
"prompt": "Replace the environment and characters throughout the video with the content from Image.",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "auto"
}
}'Responses and errors
HTTP 200
Request Successful
| Parameter | Type | Description & constraints |
|---|---|---|
codeoptional | integer | Response status code - **200**: Success - Request has been processed successfully - **401**: Unauthorized - Authentication credentials are missing or invalid - **402**: Insufficient Credits - Account does not have enough credits to perform the operation - **404**: Not Found - The requested resource or endpoint does not exist - **422**: Validation Error - The request parameters failed validation checks - **429**: Rate Limited - Request limit has been exceeded for this resource - **433**: Request Limit - Sub-key Usage Exceeds Limit - **455**: Service Unavailable - System is currently undergoing maintenance - **500**: Server Error - An unexpected error occurred while processing the request - **501**: Generation Failed - Content generation task failed - **505**: Feature Disabled - The requested feature is currently disabled Values: |
msgoptional | string | Response message, error description when failed |
datarequired | object | |
data.taskIdrequired | string | Task ID, can be used with Get Task Details endpoint to query task status |
Task status and callbacks
For asynchronous tasks, keep the returned taskId. Query GET /api/v1/jobs/recordInfo?taskId=... or provide callBackUrl when creating the task. Only the account that created a task can access it or derive new resources from it.
A timeout can mean the submission was accepted. Inspect the existing request in your dashboard; do not create another task automatically. Callback delivery is retried and may arrive more than once. Deduplicate with X-VezAPI-Event-Id.
Files, logs and billing
Generated media normally follows a 14-day provider lifetime; uploaded files expire after 24 hours. Save the files you need before expiration. VezAPI streams registered files without keeping a permanent media library. Request logs are retained for two calendar months.
Credits are reserved before submission. Final deductions match actual discounted consumption one for one. Unknown usage pauses new paid requests. If available funds cannot cover final usage while protecting other reservations, settlement stays pending until funded; model usage cannot make the wallet negative. Time-based inputs require server-side metadata reads; a failed read prevents submission.