Kling 4.0
Kling 4.0 — unified text/keyframe/reference-to-video and video editing, 3–30s at 720p/1080p with native audio.
POST /v2/videos/generate — model: "kling-4.0"
Kling 4.0 is Kuaishou's latest video model and replaces the separate text-to-video / image-to-video / Omni split with one model: a text prompt, keyframes (first, middle, and last frames — up to 10 images), reference images, reference videos, and a video to edit can all be combined in a single request. Clips run 3–30 seconds at 720p or 1080p with native audio always on, and prompts can be up to 26,000 characters.
Reference inputs by position: images are @image_1, @image_2, … in the order start → middles → end → references; videos are @video_1, @video_2, … with the edit video first.
See Video Generation overview for common request fields, response format, and error codes.
Model-specific parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
klingParams.duration | integer | 5 | Output duration in seconds (3–30). Ignored when base_video is set and omitted — the output keeps the clip's length |
klingParams.resolution | string | "1080p" | Output resolution: "720p" or "1080p" |
klingParams.aspect_ratio | string | "16:9" | "21:9", "16:9", "9:16", or "1:1". Ignored when keyframes or a base_video set the shape |
klingParams.start_image | string | — | URL of the first frame |
klingParams.middle_images | string[] | — | Keyframes between the first and last frame, in order |
klingParams.end_image | string | — | URL of the last frame |
klingParams.reference_images | string[] | — | Up to 10 images (total across all image inputs) for characters, products, scenes, or style |
klingParams.reference_videos | string[] | — | Up to 5 clips (3–30s each, 30s total) for motion / camera / style reference |
klingParams.base_video | string | — | A 3–30s clip to edit. Output keeps its length and aspect ratio |
klingParams.keep_original_sound | boolean | false | Keep the input video's audio instead of generating native audio. Requires a video input |
There is no mode, negative_prompt, or multi_prompt — write negative descriptions and shot sequences directly in the prompt.
Credit cost
Pricing is per second, keyed on resolution:
| Variant | Credits / sec |
|---|---|
720p | 20 |
1080p | 29 |
720p-refvid | 12 |
1080p-refvid | 18 |
Without video inputs the cost is credits-per-second × duration: a 10-second 1080p clip costs 29 × 10 = 290 credits.
With reference_videos or a base_video the *-refvid rate applies to the total billed duration — output + max(input, output), where input is the combined length of all input clips (same rule as the official Kling API). Editing a 5-second clip into a 5-second 1080p output bills 18 × 10 = 180 credits; a 10-second 1080p output with a 4-second reference clip bills 18 × 20 = 360 credits.
Input clips are probed before billing, so an unreadable or out-of-range video (each clip 3–30s, 30s combined) is rejected up front without deducting credits.
Example result
Once the job is COMPLETED, the result object on GET /v2/jobs/:id looks like:
{
"videoUrl": "https://cdn2.apiframe.ai/videos/b2c3d4e5-f6a7-8901-bcde-f23456789012.mp4"
}See Result format for field details.
Code examples
curl -X POST https://api.apiframe.ai/v2/videos/generate \
-H "X-API-Key: afk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Keep the character from @image_1. A slow dolly-in as she turns toward the window at golden hour.",
"model": "kling-4.0",
"klingParams": {
"duration": 10,
"resolution": "1080p",
"aspect_ratio": "21:9",
"reference_images": ["https://example.com/character.png"]
}
}'import requests
response = requests.post(
"https://api.apiframe.ai/v2/videos/generate",
headers={
"X-API-Key": "afk_your_api_key_here",
"Content-Type": "application/json",
},
json={
"prompt": "Keep the character from @image_1. A slow dolly-in as she turns toward the window at golden hour.",
"model": "kling-4.0",
"klingParams": {
"duration": 10,
"resolution": "1080p",
"aspect_ratio": "21:9",
"reference_images": ["https://example.com/character.png"],
},
},
)
print(response.json())const response = await fetch("https://api.apiframe.ai/v2/videos/generate", {
method: "POST",
headers: {
"X-API-Key": "afk_your_api_key_here",
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "Keep the character from @image_1. A slow dolly-in as she turns toward the window at golden hour.",
model: "kling-4.0",
klingParams: {
duration: 10,
resolution: "1080p",
aspect_ratio: "21:9",
reference_images: ["https://example.com/character.png"],
},
}),
});
console.log(await response.json());Try it
/v2/videos/generateTry it