Kling 4.0 API
Complete API reference for Kling 4.0 video generation models by Kuaishou.
Model Variants
This API supports five model variants:
Quick Comparison
Supported Aspect Ratios
Text-to-Video, Image-to-Video, Reference-to-Video, and Video Edit support:
16:9, 9:16, 1:1, 21:9
The default is 16:9. Video Extend does not support the aspect_ratio parameter; the output follows the source video's aspect ratio.
Resolution Options
All five models require resolution and duration. Include resolution explicitly even though its default value is 720p. duration has no default value.
Kling 4.0 Text to Video
Endpoint
POST /api/v1/video/task
Request Parameters
Required
Optional
Example Request
javascript
Kling 4.0 Image to Video
Request Parameters
Required
Optional
When both image_url and image_end_url are provided, key_frames can contain at most 8 images. Intermediate frames are used in array order; their timing is determined by the model.
Example Request
javascript
Kling 4.0 Reference to Video
Request Parameters
Required
Optional
Reference images, videos, and audio are all optional. Provide any one media type, combine media types, or omit all three.
The output duration is independently set to 3-30 seconds and does not count toward the reference videos' combined duration limit.
Example Request
javascript
Kling 4.0 Video Edit
Request Parameters
Required
Optional
Example Request
javascript
Kling 4.0 Video Extend
Request Parameters
Required
Optional
Do not send aspect_ratio; the output follows the source video's aspect ratio. The result contains the full video, including the source and the extension. Its total duration is the source video duration plus duration.
Example Request
javascript
Billing Rules
Text-to-Video and Image-to-Video are billed by output resolution and generated video duration. Video Extend is billed by resolution and the added segment's duration, not the full returned video length.
Reference-to-Video requests containing reference videos and Video Edit requests account for both input and output video duration at the selected resolution. Input video duration has a minimum billed duration of 3 seconds and a maximum of 30 seconds. For multiple reference videos, these bounds apply to their combined duration, not to each video separately. Billing duration bounds do not define upload limits.
Without reference videos, Reference-to-Video uses the same billing rules as Text-to-Video, whether or not reference images or audio are supplied. For requests with video input, supported reference images, reference audio, and keep_original_sound do not add separate charges.
Response Format
Initial Response
All models return a task_id for polling:
json
Poll with GET /api/v1/video/{task_id} to check status and retrieve the generated video.
Status Values
submitted: Task accepted and waiting to be processedprocessing: Video generation in progresssucceed: Video generation completedfailed: Video generation failed
Best Practices
- Required Parameters: Always provide
resolutionandduration, including when using the default720presolution - Frame Count: Keep the combined first, ending, and intermediate frames at 10 or fewer
- Reference Media: Keep reference media within the documented counts and durations
- Original Sound: Use
keep_original_soundonly for Reference-to-Video or Video Edit - Video Extension: Set
durationto the additional length and omitaspect_ratio