Loading API documentation
Generate videos with Kling 4.0 Flash Text to Video
The client provides a convenient way to interact with the model API.
npm install --save @fal-ai/clientSet FAL_KEY as an environment variable in your runtime.
export FAL_KEY="YOUR_API_KEY"The client API handles the API submit protocol. It will handle the request status updates and return the result when the request is completed.
import { fal } from "@fal-ai/client";
const result = await fal.subscribe("kling/v4/flash/text-to-video", {
input: {
prompt: "10 seconds, 21:9. Elegant luxury resort film, one continuous camera move, no cuts: from the unmade bed, out through the open doors, across the deck and down to the waterline as the guest takes the first swim of the day at the instant the sun breaks the horizon.
Person (keep identical throughout): Ishani Raghavan, the guest, 41, slim swimmer's build with strong shoulders, warm medium-brown skin, a few dark freckles on her shoulders, straight black hair cut in a blunt chin-length bob, strong dark eyebrows, no makeup, small plain gold stud earrings; she wears an ankle-length undyed white waffle-cotton robe over a plain black one-piece swimsuit with a low back, barefoot.
Location: Villa Seven at Thila Rah Reserve, a fictional overwater resort on a Maldives-style atoll (representative imagery): a single villa on silver-grey teak stilts above a turquoise lagoon; inside, a low king bed with rumpled ivory linen, a pale limed-oak floor, a woven pandanus ceiling, a brass reading lamp still glowing amber; floor-to-ceiling teak sliding doors standing fully open; outside, a sun-bleached teak deck with no railing on the lagoon edge, a short teak ladder down to the water, a folded sand-coloured towel on the deck; beyond, flat glassy lagoon, a far line of reef breaking white, and the sky at the moment just before sunrise: apricot at the horizon fading to pale blue overhead, no sun disc yet.
Shot (single continuous move):
0-3 s: the camera starts low beside the bed at mattress height, gliding slowly along rumpled linen toward the open doors and the glowing horizon beyond.
3-6 s: it passes through the doorway onto the deck; Ishani walks ahead of it, barefoot, to the deck edge, the lagoon spreading out across the wide frame; she lets the robe fall.
6-8 s: the camera drops smoothly to just above the waterline as she dives in cleanly; rings spread across the glassy surface.
8-10 s: the camera settles a few centimetres above the water as the first sliver of sun breaks the horizon behind her; she surfaces, slicks back her hair, and floats facing the light; hold.
Audio: no dialogue. Music: a sparse ambient piece, about 60 BPM, solo cello holding a long low note with soft harmonics, a felt piano entering at 4 s with three single notes, swelling gently to the end. Foley: linen rustle, bare feet on teak, the robe dropping onto the deck, the hush of tiny lagoon wavelets against the stilts, a single clean entry splash, distant reef surf, one white tern call.
Look: soft pre-dawn light turning warm, turquoise and apricot palette, ivory and silver teak; large-format clarity, very fine grain, realistic water.
On-screen text: one small end line in the empty sky at 9-10 s: \"Thila Rah\".
AVOID: cuts, drone footage, people other than Ishani, logos on towel or robe, text other than the end line, lens flares, oversaturated turquoise, a fully risen sun, slow motion, splashes that freeze, CGI-looking water, a railing on the deck edge."
},
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS") {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});
console.log(result.data);
console.log(result.requestId);The API uses an API Key for authentication. It is recommended you set the FAL_KEY environment variable in your runtime when possible.
import { fal } from "@fal-ai/client";
fal.config({
credentials: "YOUR_FAL_KEY"
});The client API provides a convenient way to submit requests to the model.
import { fal } from "@fal-ai/client";
const { request_id } = await fal.queue.submit("kling/v4/flash/text-to-video", {
input: {
prompt: "10 seconds, 21:9. Elegant luxury resort film, one continuous camera move, no cuts: from the unmade bed, out through the open doors, across the deck and down to the waterline as the guest takes the first swim of the day at the instant the sun breaks the horizon.
Person (keep identical throughout): Ishani Raghavan, the guest, 41, slim swimmer's build with strong shoulders, warm medium-brown skin, a few dark freckles on her shoulders, straight black hair cut in a blunt chin-length bob, strong dark eyebrows, no makeup, small plain gold stud earrings; she wears an ankle-length undyed white waffle-cotton robe over a plain black one-piece swimsuit with a low back, barefoot.
Location: Villa Seven at Thila Rah Reserve, a fictional overwater resort on a Maldives-style atoll (representative imagery): a single villa on silver-grey teak stilts above a turquoise lagoon; inside, a low king bed with rumpled ivory linen, a pale limed-oak floor, a woven pandanus ceiling, a brass reading lamp still glowing amber; floor-to-ceiling teak sliding doors standing fully open; outside, a sun-bleached teak deck with no railing on the lagoon edge, a short teak ladder down to the water, a folded sand-coloured towel on the deck; beyond, flat glassy lagoon, a far line of reef breaking white, and the sky at the moment just before sunrise: apricot at the horizon fading to pale blue overhead, no sun disc yet.
Shot (single continuous move):
0-3 s: the camera starts low beside the bed at mattress height, gliding slowly along rumpled linen toward the open doors and the glowing horizon beyond.
3-6 s: it passes through the doorway onto the deck; Ishani walks ahead of it, barefoot, to the deck edge, the lagoon spreading out across the wide frame; she lets the robe fall.
6-8 s: the camera drops smoothly to just above the waterline as she dives in cleanly; rings spread across the glassy surface.
8-10 s: the camera settles a few centimetres above the water as the first sliver of sun breaks the horizon behind her; she surfaces, slicks back her hair, and floats facing the light; hold.
Audio: no dialogue. Music: a sparse ambient piece, about 60 BPM, solo cello holding a long low note with soft harmonics, a felt piano entering at 4 s with three single notes, swelling gently to the end. Foley: linen rustle, bare feet on teak, the robe dropping onto the deck, the hush of tiny lagoon wavelets against the stilts, a single clean entry splash, distant reef surf, one white tern call.
Look: soft pre-dawn light turning warm, turquoise and apricot palette, ivory and silver teak; large-format clarity, very fine grain, realistic water.
On-screen text: one small end line in the empty sky at 9-10 s: \"Thila Rah\".
AVOID: cuts, drone footage, people other than Ishani, logos on towel or robe, text other than the end line, lens flares, oversaturated turquoise, a fully risen sun, slow motion, splashes that freeze, CGI-looking water, a railing on the deck edge."
},
webhookUrl: "https://optional.webhook.url/for/results",
});You can fetch the status of a request to check if it is completed or still in progress.
import { fal } from "@fal-ai/client";
const status = await fal.queue.status("kling/v4/flash/text-to-video", {
requestId: "764cabcf-b745-4b3e-ae38-1200304cf45b",
logs: true,
});Once the request is completed, you can fetch the result. See the Output Schema for the expected result format.
import { fal } from "@fal-ai/client";
const result = await fal.queue.result("kling/v4/flash/text-to-video", {
requestId: "764cabcf-b745-4b3e-ae38-1200304cf45b"
});
console.log(result.data);
console.log(result.requestId);Some attributes in the API accept file URLs as input. Whenever that's the case you can pass your own URL or a Base64 data URI.
You can pass a Base64 data URI as a file input. The API will handle the file decoding for you. Keep in mind that for large files, this alternative although convenient can impact the request performance.
You can also pass your own URLs as long as they are publicly accessible. Be aware that some hosts might block cross-site requests, rate-limit, or consider the request as a bot.
We provide a convenient file storage that allows you to upload files and use them in your requests. You can upload files using the client API and use the returned URL in your requests.
import { fal } from "@fal-ai/client";
const file = new File(["Hello, World!"], "hello.txt", { type: "text/plain" });
const url = await fal.storage.upload(file);Read more about file handling in our file upload guide.
prompt string* requiredText prompt for video generation.
duration integerVideo duration in seconds (3-20). Default value: 5
resolution ResolutionEnumOutput resolution. Flash is 720p only. Default value: "720p"
Possible enum values: 720p
aspect_ratio AspectRatioEnumAspect ratio of the generated video. Default value: "16:9"
Possible enum values: 16:9, 9:16, 1:1, 21:9
{
"prompt": "10 seconds, 21:9. Elegant luxury resort film, one continuous camera move, no cuts: from the unmade bed, out through the open doors, across the deck and down to the waterline as the guest takes the first swim of the day at the instant the sun breaks the horizon.\n\nPerson (keep identical throughout): Ishani Raghavan, the guest, 41, slim swimmer's build with strong shoulders, warm medium-brown skin, a few dark freckles on her shoulders, straight black hair cut in a blunt chin-length bob, strong dark eyebrows, no makeup, small plain gold stud earrings; she wears an ankle-length undyed white waffle-cotton robe over a plain black one-piece swimsuit with a low back, barefoot.\nLocation: Villa Seven at Thila Rah Reserve, a fictional overwater resort on a Maldives-style atoll (representative imagery): a single villa on silver-grey teak stilts above a turquoise lagoon; inside, a low king bed with rumpled ivory linen, a pale limed-oak floor, a woven pandanus ceiling, a brass reading lamp still glowing amber; floor-to-ceiling teak sliding doors standing fully open; outside, a sun-bleached teak deck with no railing on the lagoon edge, a short teak ladder down to the water, a folded sand-coloured towel on the deck; beyond, flat glassy lagoon, a far line of reef breaking white, and the sky at the moment just before sunrise: apricot at the horizon fading to pale blue overhead, no sun disc yet.\n\nShot (single continuous move):\n0-3 s: the camera starts low beside the bed at mattress height, gliding slowly along rumpled linen toward the open doors and the glowing horizon beyond.\n3-6 s: it passes through the doorway onto the deck; Ishani walks ahead of it, barefoot, to the deck edge, the lagoon spreading out across the wide frame; she lets the robe fall.\n6-8 s: the camera drops smoothly to just above the waterline as she dives in cleanly; rings spread across the glassy surface.\n8-10 s: the camera settles a few centimetres above the water as the first sliver of sun breaks the horizon behind her; she surfaces, slicks back her hair, and floats facing the light; hold.\n\nAudio: no dialogue. Music: a sparse ambient piece, about 60 BPM, solo cello holding a long low note with soft harmonics, a felt piano entering at 4 s with three single notes, swelling gently to the end. Foley: linen rustle, bare feet on teak, the robe dropping onto the deck, the hush of tiny lagoon wavelets against the stilts, a single clean entry splash, distant reef surf, one white tern call.\nLook: soft pre-dawn light turning warm, turquoise and apricot palette, ivory and silver teak; large-format clarity, very fine grain, realistic water.\nOn-screen text: one small end line in the empty sky at 9-10 s: \"Thila Rah\".\nAVOID: cuts, drone footage, people other than Ishani, logos on towel or robe, text other than the end line, lens flares, oversaturated turquoise, a fully risen sun, slow motion, splashes that freeze, CGI-looking water, a railing on the deck edge.",
"duration": 10,
"resolution": "720p",
"aspect_ratio": "21:9"
}The generated video.
{
"video": {
"file_size": 23599464,
"url": "https://v3b.fal.media/files/b/0ab11f9d/0WK4KLsy_4-HxwKDivOMQ_t2v.mp4",
"file_name": "output.mp4",
"content_type": "video/mp4"
}
}url string* requiredThe URL where the file can be downloaded from.
content_type stringThe mime type of the file.
file_name stringThe name of the file. It will be auto-generated if not provided.
file_size integerThe size of the file in bytes.