fal: Serverless Python Framework
fal is an easy-to-use Serverless Python Framework that enables developers to build, test, and deploy serverless applications and machine learning models on GPU-accelerated infrastructure. It offers a Python SDK for defining applications and a CLI for deployment and management. The library is actively maintained, with frequent releases, and is currently at version 1.72.1.
Warnings
- gotcha The `fal` package (for building/deploying apps) and `fal-client` package (for calling models/endpoints) are distinct. Ensure you install and import the correct one for your use case.
- gotcha Authentication is crucial. For development and deployment, use `fal auth login` via the CLI. For programmatic client calls, the `fal-client` library typically expects the `FAL_KEY` environment variable to be set, or it can be passed explicitly.
- breaking Starting with `fal>=1.61.0`, runners now receive a `SIGTERM` signal with a 5-second grace period before `SIGKILL` when terminated. This affects app cleanup during shutdown.
- gotcha When running apps locally with `fal run`, the default authentication mode is `public`. If you require API key authentication during local development, explicitly use the `--auth private` flag.
- gotcha The runner state model was updated around October 2025 to include an `IDLE` state. If you are programmatically monitoring or tracking runner states, your integrations might need updates.
Install
-
pip install fal -
pip install fal-client
Imports
- fal
import fal
- fal_client
import fal_client
- SyncServerlessClient
from fal.api import SyncServerlessClient
Quickstart
import fal
import os
# Ensure FAL_KEY is set as an environment variable (e.g., export FAL_KEY="YOUR_API_KEY")
# or authenticate via 'fal auth login' CLI command.
fal_key = os.environ.get('FAL_KEY', '')
if not fal_key:
print("Warning: FAL_KEY environment variable not set. Please authenticate via 'fal auth login' or set FAL_KEY.")
class HelloApp(fal.App):
@fal.endpoint("/")
def run(self) -> dict:
print("Processing Hello World request...")
return {"message": "Hello, World!"}
# To run locally for testing (requires fal CLI and authentication):
# fal run your_app_file.py::HelloApp
# To deploy to a persistent endpoint:
# fal deploy your_app_file.py::HelloApp