Loading API documentation
The client provides a convenient way to interact with the model API.
npm install --save @fal-ai/clientThe @fal-ai/serverless-client package has been deprecated in favor of @fal-ai/client. Install the new package and update your imports — see client setup.
Set FAL_KEY as an environment variable in your runtime.
export FAL_KEY="YOUR_API_KEY"This model has a real-time mode via WebSockets, supported by fal.realtime.connect.
import { fal } from "@fal-ai/client";
const connection = fal.realtime.connect("krea/v3/realtime", {
onResult: (result) => {
console.log(result);
},
onError: (error) => {
console.error(error);
},
// Fetch short-lived JWT token from your backend
tokenProvider: async (app) => {
const response = await fetch("/api/fal/realtime-token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ app }),
});
return response.text();
},
tokenExpirationSeconds: 10,
});
connection.send({});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"
});When running code on the client-side (e.g. in a browser, mobile app or GUI applications), make sure to not expose your FAL_KEY. Instead, use a server-side proxy to make requests to the API. For more information, check out our server-side integration guide.
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);The client will auto-upload the file for you if you pass a binary object (e.g. File, Data).
Read more about file handling in our file upload guide.
prompt stringEdit instruction. Refer to the input frame as <image-1>. Default value: "Turn <image-1> into a living oil painting, melting gold and sapphire"
seed integerLatent noise seed. A fixed seed keeps consecutive frames consistent. Default value: 35
image_url stringBase64-encoded image data URI to edit; CDN URLs are not supported. Frames are resized to 768x768. Omit it to generate from the prompt alone. Default value: "null"
{
"prompt": "Turn <image-1> into a living oil painting, melting gold and sapphire",
"seed": 35
}Edited frame as a JPEG data URI.
seed integer* requiredSeed used for generation.
Seconds spent in each stage.
{
"images": [
{
"file_size": 4404019,
"file_name": "z9RV14K95DvU.png",
"url": "",
"width": 1024,
"content_type": "image/png",
"height": 1024
}
]
}file_size integerThe size of the file in bytes.
file_name stringThe name of the file. It will be auto-generated if not provided. Default value: "null"
file_data stringFile data Default value: "null"
url string* requiredThe URL where the file can be downloaded from.
width integerThe width of the image in pixels.
content_type stringThe mime type of the file. Default value: "null"
height integerThe height of the image in pixels.