Kling 4.0 Flash
Generate a 720p video with sound from a prompt, a first frame, reference images or an existing video, billed by the output length.
Kling 4.0 Flash (product kling_flash) generates a 720p video with sound from a prompt, a first frame, reference images or a video you already have. Each mode has its own page with its parameters, price and request examples:
mode | What it does | Docs |
|---|---|---|
text_to_video | Text to video: generated from a prompt alone. | Text to Video |
image_to_video | Image to video: starts from your image as the first frame. | Image to Video |
reference_to_video | Reference to video: the people, objects or scenes in your reference images appear in a new video, optionally guided by reference videos. | Reference to Video |
video_edit | Video edit: an existing video changed as your prompt says. | Video Edit |
Create a task
https://api.nanoapi.ai/v1/tasksUse the shared create endpoint with model: "kling-4.0-flash" and one of the modes above. Parameters every mode takes:
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | kling-4.0-flash |
mode | string | Yes | text_to_video, image_to_video, reference_to_video or video_edit. |
aspect_ratio | string | Yes | auto, 21:9, 16:9, 9:16 or 1:1. What auto does depends on the mode, see its page. |
resolution | string | Yes | 720p. |
duration | integer | Conditional | Required except in video_edit. Output length in seconds, 3–20. Billed per second, see Pricing. A video_edit without it follows the video you edit, see Video Edit. |
webhook_url | string | No | Notified when the task succeeds or fails. See Webhooks. |
There are no defaults.
Get the result
A 3-second video takes about 1.3 minutes. Get the result through the webhook if you sent webhook_url, or poll GET /v1/tasks/{task_id} at most once every 15 seconds until status is succeeded or failed (several tasks at once: ids in List tasks).
| Field | Kling 4.0 Flash |
|---|---|
outputs[0].url | The generated video: an MP4 with sound (1280×720 at 16:9, 24 fps). |
outputs[0].preview_url | A silent, compressed copy for previews, see Outputs. |
billing.billed_seconds | The duration you asked for; for a video_edit without duration, the actual output length. |
input | What you sent, including aspect_ratio and duration (a video_edit sent without duration has none). prompt, image_urls, video_url and video_urls only appear if you sent them. |
Media
Pass public http(s) URLs that download directly: at most 4096 characters, not localhost or a private, loopback or reserved address, and valid until the task finishes (including signed URLs that expire). There's no upload endpoint.
| Parameter | What it is | Modes |
|---|---|---|
image_urls | Images: the first frame or reference images. | image_to_video (exactly 1), reference_to_video (up to 10), video_edit (up to 10) |
video_url | The video to edit. | video_edit |
video_urls | Reference videos. | reference_to_video (up to 5), video_edit (up to 4) |
Which ones a mode requires is on its page. Every video (video_url and each video_urls entry) must meet these requirements:
| Video requirement | Otherwise the task fails with |
|---|---|
| Each video 3–30 seconds | video_too_short / video_too_long |
All of a task's videos together at most 30 seconds (so a 30-second video_url can't carry reference videos) | video_too_long |
| 720p or higher (at least 720 pixels on the short side) | invalid_media |
| Aspect ratio at most 2.5:1 (pure black bars don't count) | invalid_media |
An image or video that can't be downloaded or read (corrupt, unsupported format) fails the task with invalid_media.
Kling 4.0 Flash reads every file only after the task is submitted for generation, a few seconds after creation, once the cost has been frozen: none of the above is checked when the task is created. If a file can't be used, the frozen amount is returned in full (the failed task's started_at may be null).
Referring to files in the prompt
In prompt | Refers to |
|---|---|
@Image1 … @Image10 | The images in image_urls, in order. |
@Video1, @Video2, … | reference_to_video: the video_urls entries, in order. video_edit: @Video1 is video_url (the video to edit), @Video2 on are the video_urls entries. |
Pricing
cost = duration × price per second of the modeLoading the current prices…
Billed seconds are the duration you ask for (3–20). They don't depend on your images, or on how long your videos are.
reference_to_videowith reference videos (video_urls) is billed at thevideo_editprice per second, see Reference to Video → Pricing.video_editwithoutduration: 20 × the price per second is frozen first; when the task succeeds, the actual output length is charged and the difference returned. See Video Edit → Pricing.
Except for a video_edit without duration, the cost is known from the request alone, so you can show it before submitting. Current prices: GET /v1/products (product kling_flash, one prices row per mode, by the row's mode; reference_to_video with reference videos uses the video_edit row). The task's billing.frozen is the amount that counts; freezing and charging: Billing.
Errors
Request errors
A request that fails returns an HTTP error, and no task is created:
{
"code": 400,
"message": "Field required",
"error": {
"type": "invalid_request",
"param": "aspect_ratio",
"details": null
},
"request_id": "rq_01jb8z9x2c4v6b8n0m1q3w5e7r"
}| HTTP status | error.type | Description |
|---|---|---|
| 400 | invalid_request | A required parameter is missing, a value breaks the rules in the parameter tables on this page or the mode pages, or a parameter isn't accepted; param names it |
| 401 | invalid_api_key | The API key is invalid, deleted or has been reset |
| 402 | insufficient_balance | Your available balance is 0 |
| 402 | spend_limit_exceeded | One of the API key's spend limits is used up |
| 403 | account_suspended | Your account has been suspended |
| 409 | idempotency_key_reused | The Idempotency-Key was already used with a different request body |
| 429 | rate_limited | Too many requests |
| 500 | internal_error | A server error; the task may have been created |
details and how to handle each error: Create a task → Errors.
Task failures
A created task can still fail: its status turns failed and the reason is in error, with no HTTP status. A failed task is never charged; anything frozen is returned in full.
{
"status": "failed",
"error": {
"type": "video_too_long",
"message": "The total duration of the videos must be at most 30 seconds."
}
}error.type | Description |
|---|---|
invalid_media | An image or a video can't be downloaded or read (corrupt or an unsupported format), or a video is below 720p or its aspect ratio is beyond 2.5:1 |
video_too_long | A video (video_url or a video_urls entry) is longer than 30 seconds, or all of the task's videos together are |
video_too_short | A video (video_url or a video_urls entry) is shorter than 3 seconds |
content_policy | The prompt or a file breaks the content policy (adult content, a protected likeness or copyrighted material) |
insufficient_balance | Your available balance can't cover this task; for a video_edit without duration, it must cover 20 seconds |
spend_limit_exceeded | This task would go over one of the API key's spend limits |
generation_failed | Generation failed |
queue_timeout | Not started within 30 minutes of being queued |
internal_error | An internal error |
Branch on error.type; message is an English explanation for developers and may change. When each reason can happen, whether anything was frozen, and the message texts: Failure reasons.