subscribe, submit, run, stream).
How you configure the client depends on where your code runs. In a server-side environment like a Python script, a Node.js backend, or a serverless function, you set your FAL_KEY as an environment variable and the client picks it up automatically. In a client-side environment like a React app running in the browser, you cannot use the API key directly because browser source code is visible to anyone. Instead, the fal client routes requests through a lightweight proxy on your server, which attaches the key before forwarding to fal. Both approaches are covered in the Configuration section below.
Installation
Java Async Support — If your code relies on asynchronous operations via
CompletableFuture or Future, use the ai.fal.client:fal-client-async artifact instead.Configuration
Server-side (Python, Node.js)
The simplest path. Set your API key as an environment variable and the client picks it up automatically:FAL_KEY from the environment on import:
Client-side (Browser, React, Next.js)
When building web apps, your API key cannot live in browser code because browser source is visible to anyone. Instead, the fal client routes requests through a lightweight proxy on your server that attaches the key before forwarding to fal. Your API key stays on the server, and all client methods (subscribe, submit, run, stream) work transparently through the proxy.
The setup has two parts: create a proxy route on your server and point the client at it. Here is the quickest path using Next.js:
app/api/fal/proxy/route.ts (App Router):
FAL_KEY is set as an environment variable on your server. The proxy reads it from the environment, just like the server-side setup above.
Proxy Setup
Pages Router, Vercel, Express, custom frameworks, and how the proxy works under the hood
Making Your First Call
Once configured, you can call any model:Client Methods
| Method | How it works | Uses Queue |
|---|---|---|
run() | Direct synchronous call | No |
subscribe() | Blocks until result, polls automatically | Yes |
submit() | Returns immediately, poll or use webhooks | Yes |
stream() | Progressive output via SSE | No |
realtime() | WebSocket connection | No |
_async suffix (e.g., subscribe_async, submit_async, run_async, stream_async, realtime_async). Use these when working with asyncio.