Kling 4.0 is Kuaishou's video model for clips of 3 to 30 seconds at 720p, 1080p, or 4K. Kuaishou presents it as a production model: stable motion, picture and sound together, and coverage of tracking shots, orbits, and close-ups. That description is from kling.ai and Kuaishou's Kling 4 note on cinematic motion, read on 29 November 2026. The Kling 4.0 API reference says a generation can take up to 10 images. Kerox follows that cap.
The call is the same task API as every other model. The ID is kuaishou/kling-4.0. Five seconds at 720p is $0.7065. Five seconds at 4K is $2.4705. Parameter reference: Kling 4.0 API docs. Editing or extending an existing video is not available on this model yet. If that is the job, Seedance 2.5 has edit and extend.
What one request can do
prompt is required in every mode, including image to video.
- Text to video. Prompt, duration, resolution, and an explicit
aspect_ratio(16:9,9:16,1:1, or21:9).autois not valid here. - First frame, or first and last frame.
first_frameis an image URL.last_frameis optional and requires the first. Do not also sendimages,videos, oraudios. The ratio is explicit, notauto. - References. Up to 10 images, 5 videos, and 3 audio clips. This is the only mode where
aspect_ratiomay beauto.keep_original_soundkeeps the reference video's audio in the result when you set it to true.
Kling 4.0 Flash (kuaishou/kling-4.0-flash) is the smaller sibling: 720p only, 3 to 20 seconds, reference images and video, no audio input. Kling Image 4.0 (kuaishou/kling-image-4.0) is a still model: one image at 2K, 4K, or 8K, with up to 10 reference images. It is not a video call. A 2K still is $0.0567.
Create a key
Sign in at API keys, create a key, and fund the wallet. The minimum top-up is $5. Put the secret in KEROX_API_KEY. Send Authorization: Bearer <your-api-key> from your server. Limits and rotation: Authentication. The shared loop, with a different model, is the quickstart.
Submit, poll, and save the MP4
POST https://api.kerox.ai/v1/tasks returns HTTP 201. Poll GET /v1/tasks/{id} every 3 seconds until succeeded or failed, for up to 10 minutes in these scripts, then download outputs[0].url. A task still processing at the deadline can be polled later with the same ID. Files expire after 7 days. Tasks.
# Needs curl and jq. KEROX_API_KEY is your key.
set -euo pipefail
API=https://api.kerox.ai/v1
AUTH="Authorization: Bearer $KEROX_API_KEY"
BODY='{
"model": "kuaishou/kling-4.0",
"input": {
"prompt": "Track a red paper sailboat as it drifts across a dark pool. Warm copper lights switch on along the edge.",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9"
}
}'
TASK_ID=$(curl -sS --fail-with-body -X POST "$API/tasks" \
-H "$AUTH" -H "Content-Type: application/json" -d "$BODY" | jq -r .id)
echo "Submitted $TASK_ID"
DEADLINE=$(( $(date +%s) + 600 ))
STATUS=processing
while [ "$STATUS" = "processing" ] && [ "$(date +%s)" -lt "$DEADLINE" ]; do
sleep 3
TASK=$(curl -sS --fail-with-body "$API/tasks/$TASK_ID" -H "$AUTH")
STATUS=$(echo "$TASK" | jq -r .status)
done
if [ "$STATUS" != "succeeded" ]; then
echo "Task $TASK_ID is $STATUS: $(echo "$TASK" | jq -c .error)"
exit 1
fi
curl -sS --fail-with-body -o result.mp4 "$(echo "$TASK" | jq -r '.outputs[0].url')"
echo "Saved result.mp4"
# pip install requests
import os
import time
import requests
API = "https://api.kerox.ai/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['KEROX_API_KEY']}"}
resp = requests.post(
f"{API}/tasks",
headers=HEADERS,
json={
"model": "kuaishou/kling-4.0",
"input": {
"prompt": "Track a red paper sailboat as it drifts across a dark pool. Warm copper lights switch on along the edge.",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
},
},
timeout=60,
)
if resp.status_code != 201:
raise SystemExit(f"HTTP {resp.status_code}: {resp.json()['error']}")
task = resp.json()
print("Submitted", task["id"])
deadline = time.time() + 600
while task["status"] == "processing" and time.time() < deadline:
time.sleep(3)
task = requests.get(
f"{API}/tasks/{task['id']}", headers=HEADERS, timeout=30
).json()
if task["status"] != "succeeded":
raise SystemExit(f"Task {task['id']} is {task['status']}: {task.get('error')}")
file = requests.get(task["outputs"][0]["url"], timeout=120)
file.raise_for_status()
open("result.mp4", "wb").write(file.content)
print("Saved result.mp4")
// Node.js 18 or later. Save as generate.mjs and run: node generate.mjs
import fs from 'node:fs/promises';
const API = 'https://api.kerox.ai/v1';
const headers = { Authorization: `Bearer ${process.env.KEROX_API_KEY}` };
const res = await fetch(`${API}/tasks`, {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'kuaishou/kling-4.0',
input: {
prompt:
'Track a red paper sailboat as it drifts across a dark pool. Warm copper lights switch on along the edge.',
duration: 5,
resolution: '720p',
aspect_ratio: '16:9',
},
}),
});
let task = await res.json();
if (res.status !== 201)
throw new Error(`HTTP ${res.status}: ${task.error.message}`);
console.log('Submitted', task.id);
const deadline = Date.now() + 10 * 60 * 1000;
while (task.status === 'processing' && Date.now() < deadline) {
await new Promise((resolve) => setTimeout(resolve, 3000));
const poll = await fetch(`${API}/tasks/${task.id}`, { headers });
if (!poll.ok) throw new Error(`HTTP ${poll.status}`);
task = await poll.json();
}
if (task.status !== 'succeeded') {
throw new Error(
`Task ${task.id} is ${task.status}: ${JSON.stringify(task.error)}`
);
}
const file = await fetch(task.outputs[0].url);
if (!file.ok) throw new Error(`Download failed: HTTP ${file.status}`);
await fs.writeFile('result.mp4', Buffer.from(await file.arrayBuffer()));
console.log('Saved result.mp4');
Image to video uses a frame URL instead of a ratio of auto. This sample file is already public:
{
"model": "kuaishou/kling-4.0",
"input": {
"prompt": "Track the red paper sailboat as it drifts across the pool",
"first_frame": "https://cdn.kerox.ai/assets/samples/kling-4.0/paper-sail-frame.jpg",
"duration": 5,
"resolution": "1080p",
"aspect_ratio": "16:9"
},
"webhook_url": "https://example.com/webhooks/kerox"
}
webhook_url replaces the poll. When the task reaches succeeded or failed, Kerox creates one notification and delivers it to a public https:// URL. A failed delivery is retried, up to 12 attempts. Deduplicate on the webhook-id header. The signing secret is in the console, not the URL. If the callback is late, poll with the task ID. Webhooks. Upload your own frames with Files; Kling image and video URLs on this model are https, not inline base64.
Idempotency-Key on the submit deduplicates a retry for 24 hours when the body is unchanged. Idempotency.
Parameters
| Field | What to send |
|---|---|
prompt | Required in every mode. |
duration | Integer 3–30. Default 5. Flash: 3–20. |
resolution | 720p (default), 1080p, or 4K. Flash: 720p only. |
aspect_ratio | 16:9, 9:16, 1:1, 21:9, or auto. auto only with reference images, video, or audio. |
first_frame, last_frame | HTTPS image URLs. Exclusive with references. |
images | One URL or up to 10. |
videos | One URL or up to 5. |
audios | One URL or up to 3. Not on Flash. |
keep_original_sound | Boolean. Use it when a reference video should keep its audio. |
There is no seed, no negative_prompt, and no n. Sending them returns 400. There is no edit mode and no extend mode on Kling 4.0 here.
Practical adjustments:
- Write the ratio down for text and frames. Leaving
aspect_ratioout is not the same asauto, andautowithout a reference file is rejected. Set16:9or9:16unless you attached references. - 4K is a different product decision than a different prompt. The per-second rate steps up at 1080p and again at 4K. Draft at 720p, then rerun the keeper.
- Flash is not "Kling 4.0 with a flag". It is a different model ID, a shorter maximum, and no audio input. A body that worked on 4.0 can fail on Flash if it includes
audiosorresolution1080p. - One still, not a contact sheet. Kling Image 4.0 returns one image. Resolutions are
2K,4K, and8K. Output ispng,jpeg, orwebp. Reference images are billed as well as the output; the model page shows that line, andPOST /v1/estimatequotes a specific request.
Studio is the same schema with a form.
What it costs
The tables below quote Kling 4.0 and Flash with no reference video. Each second of output is priced at that resolution. The official column is Kuaishou's published per-second price as the catalog stores it. Those rates are in the Kling video price table, read on 30 November 2026. The Kling 4.0 API reference lists the parameters those rates apply to. Kerox applies the model's public discount. The hold is placed when you submit and settled when the video finishes. Failure and timeout refund the hold in full.
Attaching videos switches the output rate. The reference video is then billed for the longer of its own length and the output length. The tables below do not apply to that request. Send the same body to POST /v1/estimate before you submit.
| Output | Official price | Kerox | You save |
|---|---|---|---|
| 5 s · 720p | $0.7065 | 10% | |
| 5 s · 1080p | $1.0575 | 10% | |
| 5 s · 4K | $2.4705 | 10% | |
| 10 s · 4K | $4.9410 | 10% |
Flash is 720p only, so it is not a column in that table. Do not send 1080p or 4K to kuaishou/kling-4.0-flash. A 5-second Flash clip:
| Output | Official price | Kerox | You save |
|---|---|---|---|
| 5 s · 720p | $0.4230 | 10% |
A 10-second 4K Kling 4.0 clip is $4.9410. Billing rules: Pricing and billing.
Kling Image 4.0 is per image:
| Output | Official price | Kerox | You save |
|---|---|---|---|
| 1 image · 2K | $0.0567 | 10% | |
| 1 image · 4K | $0.0846 | 10% | |
| 1 image · 8K | $0.1413 | 10% |
Which Kling call, and when to leave Kling
kuaishou/kling-4.0for 1080p or 4K, for audio references, and for clips between 21 and 30 seconds.kuaishou/kling-4.0-flashfor 720p volume, up to 20 seconds, when you do not need to pass audio.kuaishou/kling-image-4.0when the output is a still, including an 8K still.
Same key, different family, when Kling is the wrong shape: Seedance 2.5 if you need edit, extend, or a 480p draft; GPT Image 2.6 if you need a poster or a transparent PNG rather than a clip. Do not reuse a Kling body on those IDs. Each page lists the fields it accepts. The model list is the full set.
Errors
| You got | What to do |
|---|---|
HTTP 400, param points at aspect_ratio | You sent auto without reference media, or you omitted a ratio the mode requires. Set 16:9, 9:16, 1:1, or 21:9. |
HTTP 400 on first_frame together with images | Those modes are exclusive. Drop one. |
HTTP 400 on duration or resolution | 4.0 is 3–30 seconds and 720p / 1080p / 4K. Flash is 3–20 and 720p only. |
HTTP 401 | API key missing or revoked. |
HTTP 402 | Balance or the key's spend cap. A 4K hold is larger than a 720p hold for the same seconds. |
HTTP 429 | Wait out retry-after, or wait until an in-progress task ends. |
status: "failed" | The charge was returned. Submit a new task if you want another attempt. |
The full code list is Errors.
Kling 4.0, in one pass
Create the key, submit kuaishou/kling-4.0 with a prompt, a whole-second duration, a resolution, and an explicit aspect ratio, then poll or set webhook_url. Use references when you need auto framing or keep_original_sound. Draft at 720p before you spend the 4K rate. The model page has the sample clips, and the API docs have a body for each mode.


