Kling 4.0
Kling 4.0 video model: clips with sound of 3 to 30 seconds in 720p and 1080p from text and from keyframes — a first frame, up to 9 middle frames and a last frame.
Specifications
Capabilities
Description
What it does
- Text to video: describe the scene, the camera movement and the sound. Aspect ratio: 16:9, 9:16, 1:1 or 21:9.
- Keyframes: a first frame, middle frames (up to 9) and a last frame, 10 images at most. The video passes through them in order. A last frame alone works too. With keyframes, the clip takes its proportions from the images.
- In the prompt, refer to keyframes in order: @image_1, @image_2 … — the first frame, then the middle ones, then the last.
- Length: a whole number of seconds from 3 to 30 in one generation. Resolution 720p or 1080p, 24 frames per second.
- The model always creates sound: speech, music and effects from your description.
- A prompt is always required, up to 26,000 characters. English works best. A long prompt can be split into timed shots ("SHOT 1 — 0–10 s: …").
Image requirements
JPG or PNG, up to 30 MB, each side at least 300 px, proportions from 2:5 to 5:2. An https link or a data URI.
How to call
POST /v1/videos/generations with a JSON body. Keyframes go in media: [{"type": "first_frame" | "middle_frame" | "last_frame", "url": "…"}], middle frames in the order you need.
{"model": "klingai/kling-v4-08130", "prompt": "A paper boat drifts down a rain-soaked Tokyo alley at night", "duration": 5, "resolution": "1080p", "aspect_ratio": "16:9"}From keyframes:
{"model": "klingai/kling-v4-08130", "prompt": "Start on @image_1, pass through @image_2 and end on @image_3.", "duration": 10, "resolution": "720p", "media": [{"type": "first_frame", "url": "https://example.com/1.jpg"}, {"type": "middle_frame", "url": "https://example.com/2.jpg"}, {"type": "last_frame", "url": "https://example.com/3.jpg"}]}Response
The response arrives when the video is ready: usually in 2 to 5 minutes, about 7 to 8 minutes for a 30-second clip. Set a client timeout of at least 16 minutes and send an Idempotency-Key header: repeating a request with the same key does not start a second paid generation; it waits for and returns the clip already paid for. data[0].url is a link to the MP4 file (it lives one day, save the file right away).
Errors
- 400: invalid input; the error text names the field. input_moderation: a file could not be downloaded from its link, or the prompt and images did not pass the content check. input_invalid_media: an image is smaller than 300 px or has unsuitable proportions. Rejected requests are not billed.
- 402: not enough funds on the balance. 429: the model is overloaded. 502 or 504: the video was not received; nothing is charged.
Price
You pay per second of the finished clip. The rate depends on the resolution (720p or 1080p). The prices are shown on this page.
Parameters
Endpoints
Code examples
Similar models: video
/v1 in base_url. For Anthropic SDK — without /v1.