Kling 4.0 API
Kuaishou Kling 4.0 — text-to-video, image-to-video and reference-to-video with 3-30 second clips, 720p and 1080p output, and synchronized stereo audio generated with the picture.
Three endpoints: kwaivgi/kling-v4.0/text-to-video turns a prompt into a clip, image-to-video animates a first frame with an optional last frame and keyframes, and reference-to-video builds a new clip from up to 10 images, 5 videos and 3 audios. Every endpoint takes any length from 3 to 30 seconds at 720p or 1080p.
Overview
About the Kling 4.0 API
What Kling 4.0 does, how it fits in the Kuaishou model lineup, and why teams reach for it.
Kling 4.0 is a video generation model from Kuaishou, available through the WaveSpeedAI REST API. Kuaishou Kling 4.0 — text-to-video, image-to-video and reference-to-video with 3-30 second clips, 720p and 1080p output, and synchronized stereo audio generated with the picture.
Three endpoints: kwaivgi/kling-v4.0/text-to-video turns a prompt into a clip, image-to-video animates a first frame with an optional last frame and keyframes, and reference-to-video builds a new clip from up to 10 images, 5 videos and 3 audios. Every endpoint takes any length from 3 to 30 seconds at 720p or 1080p.
The Kling 4.0 family on WaveSpeedAI ships 3 REST endpoints covering Text-To-Video, Image-To-Video, Reference-To-Video workflows. Each variant carries its own pricing, parameter knobs, and example outputs — pick the one that matches your input modality and production constraints, or call several from the same API key to compose multi-step pipelines.
Run Kling 4.0 through the same API key, billing account, and rate-limit envelope you use for the other 1,000+ AI models on WaveSpeedAI. No separate vendor setup, no per-provider SDKs, no per-vendor rate-limit envelopes — one integration covers everything from text-to-image and text-to-video through audio synthesis, 3D generation, upscaling, and editing.
Specs
Kling 4.0 API capabilities and release status
The model-specific details developers search for before choosing an API: availability, expected output length, reference support, and the current live fallback.
Endpoints
3 variants
Text-to-video, image-to-video and reference-to-video.
Duration
3-30 s
Any length from 3 to 30 seconds; 5 s is the default.
Resolution
720p / 1080p
720p is the default.
References
10 images + 5 videos + 3 audios
On reference-to-video, alongside a text prompt.
Endpoints
All Kling 4.0 API endpoints
3 Kling 4.0 endpoints available now on WaveSpeedAI — pick the variant that matches your workflow.
/filters:quality(82)/media/images/d30a6613-c770-408a-82da-6561afe428f2.webp)
Kling v4.0 Text To Video
Kling V4.0 Text-to-Video generates cinematic clips of 3 to 30 seconds from a text prompt, with 720p and 1080p output, four aspect ratios including 21:9 ultrawide, and synchronized stereo audio. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
/filters:quality(82)/media/images/2f854b02-6af0-40c0-a820-c4c52bec314a.webp)
Kling v4.0 Image To Video
Kling V4.0 Image-to-Video animates a first frame into a clip of 3 to 30 seconds, with an optional last frame and up to 8 in-between keyframes to direct the story, 720p and 1080p output and synchronized stereo audio. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
/filters:quality(82)/media/images/61c6cd42-d051-4094-981f-6cfaa207f6ab.webp)
Kling v4.0 Reference To Video
Kling V4.0 Reference-to-Video builds a new clip of 3 to 30 seconds from up to 10 reference images, 5 reference videos and 3 reference audios, following the subjects, motion and camera you point to in the prompt, with 720p and 1080p output and synchronized stereo audio. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
Examples
See Kling 4.0 in action
Real outputs generated by the Kling 4.0 API. Hover any video to preview, click to open the full-size viewer.
How to
How to use the Kling 4.0 API
Four steps from signup to a finished generation. Full Python, Node.js, and cURL examples are in the API section below.
- 01
Get an API key
Sign up for a WaveSpeedAI account and copy your API key from the dashboard. New accounts come with free starter credits — enough to run the playground a few dozen times before billing kicks in.
- 02
Submit a prediction
POST your input as JSON to https://api.wavespeed.ai/api/v3/kwaivgi/kling-v4.0/text-to-video. The endpoint returns a prediction id immediately — generations are async so you don't hold an open connection during inference.
- 03
Poll for completion
GET https://api.wavespeed.ai/api/v3/predictions/{request_id}/result. Return outputs on completed; stop with an error on failed, cancelled, timeout, or deleted; continue polling for every other status.
- 04
Read the output URL
Once status is "completed", read the URL from data.outputs[0]. The URL points to your generated media on the WaveSpeedAI CDN — image, video, audio, or 3D file depending on the Kling 4.0 variant you called.
Use cases
What you can build with Kling 4.0
Common workflows developers and creators use the Kling 4.0 API for.
Long single takes
kwaivgi/kling-v4.0/text-to-video generates any length from 3 to 30 seconds in one pass, leaving room for real action and camera movement instead of stitching short clips together.
Ultrawide cinematic framing
Text-to-video renders 16:9, 9:16, 1:1 or 21:9, so one prompt can serve a widescreen trailer, a vertical social post or an ultrawide cinematic shot.
Direct the story with keyframes
kwaivgi/kling-v4.0/image-to-video uses your image as the first frame and accepts an optional last frame plus in-between keyframes, up to 10 images in total, so you decide where the clip starts, passes through and ends.
Scenes built from mixed references
kwaivgi/kling-v4.0/reference-to-video combines up to 10 reference images, 5 reference videos and 3 reference audios, which the prompt refers to as @Image1, @Video1 and @Audio1.
Borrow a camera move or a performance
Point to a reference video in the prompt to reuse its camera movement or follow its performance, while the output length is chosen independently of the reference.
Sound generated with the picture
Every endpoint produces synchronized stereo audio together with the video. On reference-to-video you can instead keep the reference video's own sound.
Tips
Tips for prompting Kling 4.0
Practical advice for getting better outputs from Kling 4.0 — drawn from the patterns that work across video models in production pipelines.
- 01
Name the subject, action, setting and camera
Give the model a subject, what it does, where it happens and how the camera moves, for example a slow dolly-in or a handheld tracking shot. For longer clips, describe how the scene develops from beginning to end.
- 02
Describe the sound you want
Audio is generated together with the picture, so name the ambience, music or line of dialogue you want to hear in the prompt.
- 03
Say what each reference is for
On kwaivgi/kling-v4.0/reference-to-video, refer to inputs as @Image1, @Video1 and @Audio1 in the order you provide them, and say how each one should appear, for example the character from @Image1 walking through the street from @Image2.
- 04
Keyframes are used in order
On kwaivgi/kling-v4.0/image-to-video, in-between keyframes are used in the order you list them, and the first frame, keyframes and last frame add up to at most 10 images. Describe the change that connects the frames.
- 05
Draft at 720p, deliver at 1080p
Explore ideas at 720p and a short duration, then re-run the chosen prompt at 1080p for delivery.
Pricing
Kling 4.0 API pricing
Pricing is per-output. The final charge scales with the parameters you set in each variant's playground (resolution, duration, output count, references).
| Endpoint | Type | Starting price |
|---|---|---|
| kwaivgi/ | text-to-video | $0.785 |
| kwaivgi/ | image-to-video | $0.785 |
| kwaivgi/ | reference-to-video | $0.785 |
API
Call the Kling 4.0 API
Sign up for an API key at wavespeed.ai/accesskey, then submit a prediction via REST. The playground generates ready-to-paste samples for any combination of inputs.
POSThttps://api.wavespeed.ai/api/v3/kwaivgi/kling-v4.0/text-to-video
# 1. Submit the prediction.
SUBMIT_RESPONSE=$(curl --silent --show-error --fail-with-body \
-X POST "https://api.wavespeed.ai/api/v3/kwaivgi/kling-v4.0/text-to-video" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $WAVESPEED_API_KEY" \
-d '{
"prompt": "A cinematic shot of a city at sunset, soft golden light",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}')
TASK=$(printf '%s' "$SUBMIT_RESPONSE" | jq 'if has("data") then .data else . end')
PREDICTION_ID=$(printf '%s' "$TASK" | jq -r '.id')
if [ -z "$PREDICTION_ID" ] || [ "$PREDICTION_ID" = "null" ]; then
printf 'Submission response did not contain a prediction id
' >&2
exit 1
fi
RESULT_URL="https://api.wavespeed.ai/api/v3/predictions/$PREDICTION_ID/result"
# 2. Poll until the prediction finishes.
while true; do
RESPONSE=$(curl --silent --show-error --fail-with-body "$RESULT_URL" \
-H "Authorization: Bearer $WAVESPEED_API_KEY")
RESULT=$(printf '%s' "$RESPONSE" | jq 'if has("data") then .data else . end')
STATUS=$(printf '%s' "$RESULT" | jq -r '.status')
case "$STATUS" in
completed) printf '%s\n' "$RESULT" | jq '.outputs'; break ;;
failed|cancelled|timeout|deleted) printf '%s\n' "$RESULT" | jq . >&2; exit 1 ;;
*) sleep 2 ;;
esac
doneconst submitUrl = "https://api.wavespeed.ai/api/v3/kwaivgi/kling-v4.0/text-to-video";
const apiKey = process.env.WAVESPEED_API_KEY;
if (!apiKey) throw new Error('Set WAVESPEED_API_KEY');
async function requestJson(url, options = {}) {
const response = await fetch(url, options);
if (!response.ok) throw new Error(await response.text());
return response.json();
}
// 1. Submit the prediction.
const body = await requestJson(submitUrl, {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"prompt": "A cinematic shot of a city at sunset, soft golden light",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}),
});
const task = body.data ?? body;
const resultUrl = `https://api.wavespeed.ai/api/v3/predictions/${task.id}/result`;
// 2. Poll until the prediction finishes.
while (true) {
const resultBody = await requestJson(resultUrl, {
headers: { "Authorization": `Bearer ${apiKey}` },
});
const result = resultBody.data ?? resultBody;
if (result.status === "completed") {
console.log(result.outputs);
break;
}
if (["failed", "cancelled", "timeout", "deleted"].includes(result.status)) throw new Error(JSON.stringify(result));
await new Promise(resolve => setTimeout(resolve, 2000));
}import json
import os
import time
from urllib.request import Request, urlopen
api_key = os.environ["WAVESPEED_API_KEY"]
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
payload = {
"prompt": "A cinematic shot of a city at sunset, soft golden light",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}
def request_json(url, data=None):
request = Request(url, data=data, headers=headers, method="POST" if data else "GET")
with urlopen(request) as response:
return json.load(response)
# 1. Submit the prediction.
body = request_json("https://api.wavespeed.ai/api/v3/kwaivgi/kling-v4.0/text-to-video", json.dumps(payload).encode())
task = body.get("data", body)
result_url = f"https://api.wavespeed.ai/api/v3/predictions/{task['id']}/result"
# 2. Poll until the prediction finishes.
while True:
result_body = request_json(result_url)
result = result_body.get("data", result_body)
status = result.get("status")
if status == "completed":
print(result.get("outputs", []))
break
if status in {"failed", "cancelled", "timeout", "deleted"}:
raise RuntimeError(result)
time.sleep(2)Compare
Kling 4.0 vs alternatives
When to pick Kling 4.0 over similar models on WaveSpeedAI.
Kling 4.0 vs Kling 3.0
Kling 3.0 offers Standard, Pro and 4K tiers and a separate motion-control endpoint. Kling 4.0 is one set of three endpoints with 3-30 second clips, and it adds reference-to-video with mixed image, video and audio references.
Kling 4.0 vs Seedance 2.5
Seedance 2.5 also reaches 30-second single shots and adds video editing and extension endpoints. Kling 4.0 focuses on text-, image- and reference-driven generation, with up to 10 images, 5 videos and 3 audios as references.
Kling 4.0 vs Wan 3.0
Wan 3.0 offers text-, image- and reference-to-video up to 30 seconds at up to 1080p. Kling 4.0 covers the same range and is the pick when you want 21:9 ultrawide output, first, last and in-between keyframe control, or mixed image, video and audio references.
FAQ
Kling 4.0 API — Frequently asked questions
Pricing, license, integration — common questions about running Kling 4.0 on WaveSpeedAI.
What is the Kling 4.0 API?
Kling 4.0 is a Kuaishou video generation model exposed as a REST API on WaveSpeedAI. Kuaishou Kling 4.0 — text-to-video, image-to-video and reference-to-video with 3-30 second clips, 720p and 1080p output, and synchronized stereo audio generated with the picture. You can call it programmatically or try it from the playground linked above.
How do I call the Kling 4.0 API?
Sign up for a WaveSpeedAI account, copy your API key from /accesskey, then POST to https://api.wavespeed.ai/api/v3/kwaivgi/kling-v4.0/text-to-video with your input as JSON. The endpoint returns a prediction id. Poll the result endpoint starting around every 2 seconds, increase the interval for long-running tasks, and stop on any terminal status. Production-oriented Python / Node.js / cURL examples are above.
How much does the Kling 4.0 API cost?
Kling 4.0 starts at $0.785 per run. The exact cost scales with the parameters you set (resolution, duration, output count, references). The live cost preview next to the Generate button in the playground shows the exact price for your current input.
Which Kling 4.0 variants are available?
WaveSpeedAI hosts 3 live Kling 4.0 endpoints: kwaivgi/kling-v4.0/text-to-video, kwaivgi/kling-v4.0/image-to-video, kwaivgi/kling-v4.0/reference-to-video. Each variant has its own playground page and pricing.
Can I use Kling 4.0 outputs commercially?
Commercial usage rights follow the Kuaishou model license. Most Kuaishou models permit commercial output use; see each model's playground page for the specific license summary, and WaveSpeedAI's Terms of Service for platform-level conditions.
Why use Kling 4.0 on WaveSpeedAI instead of going direct?
One API key + one billing account across Kling 4.0 AND 1,000+ other AI models from other providers. No per-vendor SDK setup, no separate rate-limit envelopes, no rewrite-per-vendor integration code. Pricing is typically at parity with or below Kuaishou's direct API.
Provider
About Kuaishou
The team behind Kling 4.0 and the broader Kuaishou model lineup on WaveSpeedAI.
Kuaishou is a major Chinese short-video platform and the team behind the Kling family of video generation models. Kling 3.0 ships Standard, Pro, and 4K tiers with native audio synthesis (a sound parameter on every variant), plus a dedicated motion-control endpoint that transfers motion from a reference video to animate a still character image.
Start building with Kling 4.0 on WaveSpeedAI
Free starter credits on signup. One API key across 1,000+ AI models from Kuaishou and every other provider.