Kling 4.0 Text to Video API
https://api.hiapi.ai /v1/tasks Image, video, and audio models are called through theUnified Async API POST /v1/tasks endpoint; only the input fields differ (see input parameters below).
Model summary
| Model | kling-4.0/text-to-video |
|---|---|
| Type | Video generation (text to video) |
| Endpoint | POST /v1/tasks |
| Price | See HiAPI pricing |
Kling 4.0 text-to-video API by Kuaishou Kling. Turn a prompt into a 3–30 second cinematic clip with synchronized audio generated in the same pass, at 720p or 1080p in 16:9, 9:16, 1:1 or 21:9.
Production guidance
- Send callback.url in the request body in production so HiAPI notifies your service when the task reaches a terminal state instead of polling on a timer.
- 1080p and long clips queue noticeably longer; set client timeouts to at least 30 minutes.
- Keep callback.when at final for now. Both success and fail can trigger the terminal notification, so handlers must be idempotent per taskId.
Best suited for
Picture and synchronized audio are generated together, so ambience, engines or instruments written into the prompt arrive with the shot.
promptAny whole duration from 3 to 30 seconds, suited to one-take product demos, atmosphere shots and narrative openers.
duration16:9, 9:16, 1:1 and 21:9 ultrawide cover feed ads, vertical social video and widescreen in one prompt.
aspect_ratioValidate composition at 720p, then ship at 1080p. Per-second billing with no minimum keeps short tests cheap.
resolutiondurationRequest parameters
model string required Always kling-4.0/text-to-video.
input object required Business parameters. All Kling 4.0 text-to-video options live here.
prompt string required What the shot shows: subject, action and camera movement, up to 2500 characters. Put the ambience and sound sources you want in this same description.
resolution enum optional Output resolution. Higher resolution costs more per second and renders noticeably slower.
duration integer optional Clip length in seconds, any whole number from 3 to 30. Billed per output second with no minimum.
aspect_ratio enum optional Framing of the output. 21:9 gives an ultrawide cinematic frame.
callback object optional Optional callback. When set, HiAPI notifies your service as soon as the task reaches a terminal state, so you can poll less.
url string required Required when callback is present: the HTTPS endpoint that receives the terminal-state notification.
when enum optional When to fire the callback. Keep it at final for now.
Example requests
720p / 16:9 / 5s, testing layered steam, low golden light and engine sound.
{
"model": "kling-4.0/text-to-video",
"input": {
"prompt": "An old steam train pulls slowly out of a mountain station at dawn, thick white steam billowing into low golden sunlight, pine forest on both sides, slow lateral tracking shot, cinematic depth of field, natural engine rumble and distant birdsong",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}
}1080p / 16:9 / 5s, checking rain highlights, neon bokeh and the instrument sound.
{
"model": "kling-4.0/text-to-video",
"input": {
"prompt": "A lone violinist plays on a rain-soaked rooftop at blue hour, neon signs blurring behind her, rain droplets catching rim light, slow push-in, shallow depth of field, cinematic",
"resolution": "1080p",
"duration": 5,
"aspect_ratio": "16:9"
}
}720p / 9:16 / 8s for vertical placements at a lower cost.
{
"model": "kling-4.0/text-to-video",
"input": {
"prompt": "Vertical close-up of iced coffee pouring into a glass on a sunlit counter, condensation sliding down the glass, camera locked off, soft cafe ambience",
"resolution": "720p",
"duration": 8,
"aspect_ratio": "9:16"
}
}Getting the result
- The create call returns a taskId immediately; generation continues in the background.
- In production, wait for the callback.url notification. For local debugging, poll GET /v1/tasks/:id.
- When status is success, download the video from output[].url.
- When status is fail, fix the request based on the returned error instead of retrying the same invalid payload.
FAQ
Which resolutions and durations does Kling 4.0 text-to-video support?
720p and 1080p, with any whole duration from 3 to 30 seconds (5s by default). Billing is per output second and per resolution tier, with no minimum charge. See the pricing page for live prices.
Does the output include audio?
Yes. Audio is produced in the same pass as the picture and the MP4 ships with a soundtrack. There is no separate audio switch: describe the ambience and sound sources you want in the prompt.
How do I retrieve the finished video?
The create call returns a taskId immediately. Once the task reaches a terminal state, download the video from output[].url. In production send callback.url so HiAPI pushes the terminal state instead of you polling.
Does it support image-to-video?
This model is text-only. Use kling-4.0/image-to-video when a specific first frame has to start the clip.