Video generation API
Kling 4.0 API
Kling Video 4.0. Up to 30 seconds at 1080p with native audio and dialogue: text, start/end frames, reference images and videos, or edit an existing clip. Flash tier: faster and cheaper at 720p, up to 20 seconds.
Pay as you go, no subscription.
- Image to video
- Sound included
Quickstart
Three steps from zero to a finished file.
- 1
- 2
Send one request
POST your input to the endpoint. You get a job ID back right away.
- 3
Collect the result
Poll the status URL or pass a webhook. The finished file arrives as a link.
Or let your AI coding tool do it
Copy this prompt into Claude Code, Cursor or Codex. It reads our docs and writes the code.
Add the Pixel Dojo Kling 4.0 API to this project. Read https://pixeldojo.ai/llm/kling-4-0.txt for the endpoint, inputs and prices, and https://pixeldojo.ai/llm.txt for auth, job status and webhooks. Read the key from the PIXELDOJO_API_KEY environment variable. Write one function that submits a job, waits for it to finish and returns the file URL, with errors handled.
https://pixeldojo.ai/api/v1/models/kling-4-0/runcurl -X POST "https://pixeldojo.ai/api/v1/models/kling-4-0/run" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "0-4s: slow push in on a barista in a rainy cafe. 4-10s: she looks up and says \"Last order of the night.\" Audio: rain on glass, espresso hiss.",
"duration": 10,
"resolution": "1080p"
}'Want the file in one call? Add ?wait=60 to the URL. The request waits for the job and returns the result.
Pricing
You pay per second of video. Every setting is in the table.
| Setting | Per second | 5 second clip |
|---|---|---|
| 720p | $0.281 | $1.41 |
| 1080p | $0.406 | $2.03 |
| 4K | $0.938 | $4.69 |
| Model: Kling 4.0 | $0.406 | $2.03 |
| Model: Kling 4.0 Flash (needs Resolution 720p) | $0.156 | $0.78 |
Pay as you go
Top up from $5. No subscription and no minimum.
Failed runs cost nothing
If a run fails, you get the money back on its own.
Know the price first
Add
?dry_run=trueto any request to get its price. Nothing is charged.
Try it
Run a real request and see the exact input and output your code will handle. It is charged like any API call.
Made with this API
Real outputs. Open one to see the request that made it.
A cinematic slow dolly-in on an astronaut standing on a rocky alien beach at sunset. Twin suns glow on the horizon, salt spray drifts across the lens, the visor catches warm orange light as the astronaut slowly turns toward camera. Anamorphic lens, gentle handheld float, sharp focus on the helmet.
Slow tilt-up reveal from dusty boots to a lone explorer standing at the edge of a desert canyon at golden hour, dust particles floating in a sunbeam, wind moving her scarf. Cinematic wide shot.
A woman in a long black coat walks slowly toward the camera down a rain-wet neon-lit alley at night, pink and cyan signs reflecting in puddles, steam rising from a vent. Slow forward dolly, anamorphic lens flares, cinematic.
Slow-motion shot of a golden retriever leaping to catch a red frisbee mid-air in a sunny park, fur rippling, ears flying, dramatic backlight through the trees. Pet brand commercial.
A dancer in a loose white shirt moves through a fluid hip-hop routine in front of a colorful gradient studio wall, sharp hits on the beat, smooth arm waves, the camera steady at chest height. Bright, social-ready.
A matte black wireless headphone set rests on a slowly turning white pedestal and completes one smooth 360-degree rotation. Soft seamless backdrop fading from pale grey to warm white, large overhead softbox key light, a thin rim light catching the edges of the ear cups, gentle reflection on the pedestal. Locked-off camera, no cuts, no text, no logos. Quiet studio ambience.
Reference
Every input the endpoint takes, and what comes back.
Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
promptrequiredstringWhat happens in the clip. Timed beats, camera moves and quoted dialogue all work. Refer to inputs as <<<image_1>>> (frames first, then reference images) and <<<video_1>>> (source video first, then reference videos). | string | What happens in the clip. Timed beats, camera moves and quoted dialogue all work. Refer to inputs as <<<image_1>>> (frames first, then reference images) and <<<video_1>>> (source video first, then reference videos). | - |
tierenum · default standardstandard = Kling 4.0 (up to 30 s, 720p, 1080p or 4k). flash = Kling 4.0 Flash: faster and cheaper, 720p only, up to 20 s, start frame only (no end frame).standard Kling 4.0flash Kling 4.0 Flash | enum | standard = Kling 4.0 (up to 30 s, 720p, 1080p or 4k). flash = Kling 4.0 Flash: faster and cheaper, 720p only, up to 20 s, start frame only (no end frame).standard Kling 4.0flash Kling 4.0 Flash | standard |
imageurlOptional first frame. The image sets the aspect ratio. | url | Optional first frame. The image sets the aspect ratio. | - |
last_frame_imageurlOptional last frame. Requires image. Not on flash. | url | Optional last frame. Requires image. Not on flash. | - |
reference_imagesarrayUp to 10 images (frames included) for cast, products, locations or a storyboard.items: urlmax items: 10 | array | Up to 10 images (frames included) for cast, products, locations or a storyboard.items: urlmax items: 10 | - |
videourlA clip to edit with the prompt (swap a product, add or remove a subject, restyle). Set duration to the clip length; billed at the video-input rate. | url | A clip to edit with the prompt (swap a product, add or remove a subject, restyle). Set duration to the clip length; billed at the video-input rate. | - |
reference_videosarrayUp to 5 clips (30 s total) whose motion, camera path or structure to carry over. Billed at the video-input rate.items: urlmax items: 5 | array | Up to 5 clips (30 s total) whose motion, camera path or structure to carry over. Billed at the video-input rate.items: urlmax items: 5 | - |
resolutionenum · default 1080pOutput resolution: 720p, 1080p or 4k. Defaults to 1080p (Flash: 720p, its only option).720p1080p4k | enum | Output resolution: 720p, 1080p or 4k. Defaults to 1080p (Flash: 720p, its only option).720p1080p4k | 1080p |
aspect_ratioenum · default 16:9Output shape for text-to-video and reference images. A start frame or source clip sets its own shape.16:99:161:121:9 | enum | Output shape for text-to-video and reference images. A start frame or source clip sets its own shape.16:99:161:121:9 | 16:9 |
durationinteger · default 5Clip length in seconds (3-30, flash 3-20). With video, the source clip length.min: 3 | max: 30 | integer | Clip length in seconds (3-30, flash 3-20). With video, the source clip length.min: 3 | max: 30 | 5 |
What comes back
When you submit (202)
{
"jobId": "job_abc123...",
"status": "pending",
"statusUrl": "https://pixeldojo.ai/api/v1/jobs/job_abc123...",
"priceUsd": 4.0625,
"creditCost": 65,
"creditsRemaining": 95,
"expiresAt": "2026-12-03T22:57:49Z"
}When it finishes
{
"jobId": "job_abc123...",
"status": "completed",
"output": {
"video": "https://temp.pixeldojo.ai/pixeldojotemp/1705930123-456789.mp4"
},
"creditCost": 65,
"expiresAt": "2026-12-03T22:57:49Z"
}priceUsd is what the run cost, in dollars. The credit fields show the same charge and your balance in account credits.
Use saved characters (@Name)
Write @Name in the prompt to use a character, product, outfit, location, prop or style saved in the account's Character Studio, for example "@Mara on a beach at sunset". Its photos are added to reference_images automatically, after any images you send yourself, so your own image numbering is unchanged. List saved names with GET /api/v1/characters and save new ones with POST /api/v1/characters. An @word that names nothing saved stays plain text.
Aspect ratios
Other endpoints for this model
Image editing and generation can use different model IDs.
- Previous version/api/v1/models/kling-video/run
Built for AI agents
Hand these to a coding assistant and it can write the integration for you.
Questions
How much does the Kling 4.0 API cost?
From $0.156 a second. The table above has the price for every setting, and each job's response shows what it cost.
Do I need a subscription?
No. Top up from $5 and pay only for what you run.
Can I see the price before I run something?
Yes. Add ?dry_run=true to the request. You get its price back. Nothing is charged and no job starts.
Do I pay for a run that fails?
No. If a run fails, you get the money back on its own.
How long do output links last?
One hour. Download the file in that time, or call the save endpoint to keep it in your library.
Can an AI assistant use this model?
Yes. Connect Claude, ChatGPT or any agent to our MCP server at https://pixeldojo.ai/mcp. Or give it the docs file for this model.
More video APIs
Same key, same request shape. Switch models by changing one word in the URL.
Kling Motion Control v3 Standard API
From $0.188 a second
Kling Motion Control v3 Pro API
From $0.25 a second
Kling Avatar API
From $0.125 a second
MiniMax H3 Turbo API
From $0.060 a second
WAN 3.0 API
From $0.069 a second
Seedance 2.5 API
From $0.375 a second
WAN 2.2 Image-to-Video API
From $0.034 a second
Seedance 2 Reference API
From $0.25 a second
Start building
Get an API key
One key works for every model.
See usage
Requests, spend and logs.
Top up
Add money to your balance, from $5.