Model Endpoints

The fal client

The client libraries offer convenient ways to interact with fal functions.


The fal client is available through the standard package manager for each supported language:

npm install --save @fal-ai/serverless-client

Initialize the client

The client assumes by default that you have a FAL_KEY, or a combination of FAL_KEY_ID and FAL_KEY_SECRET, environment variables so API authorization is handled automatically.

If you want to manually provide credentials, the JS client allows for manually set credentials so you can handle it yourself in your app code.

  credentials: "FAL_KEY_ID:FAL_KEY_SECRET", // or a function that returns a string

Subscribe to queue updates

The client offers a way for you to subscribe to queue updates. This is useful if you want to get notified when a function is done running, or if you want to get the logs as they are being generated.

import * as fal from "@fal-ai/serverless-client";
const result = await fal.subscribe(FUNCTION_ID, {
  input: {
    seed: 176400,
  pollInterval: 5000,
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") { => log.message).forEach(console.log);

The onQueueUpdate callback will be called every time the queue status changes. The update object contains the queue status data as documented on the status types section.

Run functions

The client offers a way for you to run functions. This is useful if you want to run a function that execute fast and wait for the result.

import * as fal from "@fal-ai/serverless-client";
const result = await;

2023 © Features and Labels Inc.