{"id":6624,"library":"fal","title":"fal: Serverless Python Framework","description":"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.","status":"active","version":"1.72.1","language":"en","source_language":"en","source_url":"https://github.com/fal-ai/fal","tags":["serverless","mlops","ai","gpu","cloud","framework"],"install":[{"cmd":"pip install fal","lang":"bash","label":"Install fal for app development and deployment"},{"cmd":"pip install fal-client","lang":"bash","label":"Install fal-client for consuming models and endpoints"}],"dependencies":[{"reason":"Used for calling fal Model APIs or your own deployed fal apps from Python code.","package":"fal-client","optional":true}],"imports":[{"note":"Used for defining serverless applications with fal.App and decorators.","symbol":"fal","correct":"import fal"},{"note":"Used for interacting with deployed fal models or applications as a client.","symbol":"fal_client","correct":"import fal_client"},{"note":"Used for programmatic management of fal apps, runners, keys, and secrets without the CLI or async/await. Introduced around October 2025.","symbol":"SyncServerlessClient","correct":"from fal.api import SyncServerlessClient"}],"quickstart":{"code":"import fal\nimport os\n\n# Ensure FAL_KEY is set as an environment variable (e.g., export FAL_KEY=\"YOUR_API_KEY\")\n# or authenticate via 'fal auth login' CLI command.\nfal_key = os.environ.get('FAL_KEY', '')\nif not fal_key:\n    print(\"Warning: FAL_KEY environment variable not set. Please authenticate via 'fal auth login' or set FAL_KEY.\")\n\nclass HelloApp(fal.App):\n    @fal.endpoint(\"/\")\n    def run(self) -> dict:\n        print(\"Processing Hello World request...\")\n        return {\"message\": \"Hello, World!\"}\n\n# To run locally for testing (requires fal CLI and authentication):\n# fal run your_app_file.py::HelloApp\n\n# To deploy to a persistent endpoint:\n# fal deploy your_app_file.py::HelloApp","lang":"python","description":"This quickstart demonstrates defining a simple 'Hello World' serverless application using `fal.App` and the `@fal.endpoint` decorator. It highlights the basic structure for a deployable application. Local testing and deployment are typically handled via the `fal` CLI after installing the `fal` package and authenticating."},"warnings":[{"fix":"Use `pip install fal` for app development/deployment, `pip install fal-client` for calling APIs. Import `fal` for app definition and `fal_client` for client interactions.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Run `fal auth login` in your terminal. For client SDK usage, ensure `export FAL_KEY=\"your-api-key-here\"` is set in your environment or provide `api_key` argument to client constructors.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement a `teardown()` method in your `fal.App` class to handle graceful cleanup within the 5-second grace period.","message":"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.","severity":"breaking","affected_versions":">=1.61.0"},{"fix":"Execute `fal run your_app.py::MyApp --auth private` to enforce private authentication during local testing.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update any integrations that consume runner state information to correctly handle the new `IDLE` state. Refer to the 'Understanding Runners' guide in the fal documentation.","message":"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.","severity":"gotcha","affected_versions":"Versions released after Oct 2025 (approximately >=1.60.0)"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}