Synchronous Python client for fal Serverless. Manage apps, runners, and deployments programmatically.
The SyncServerlessClient is the synchronous Python client for interacting with fal Serverless.
Its namespaces and methods mirror the CLI so you can automate the same workflows from Python.
from fal.api import SyncServerlessClientclient = SyncServerlessClient( host=None, # Optional. Override API host api_key=None, # Optional. If omitted, read from env/profile profile=None, # Optional. Named profile to use team=None, # Optional. Team context for runner ops)
apps = client.apps.list()# Optional app name filterfiltered = client.apps.list(filter="stable")# List apps in a specific environmentstaging_apps = client.apps.list(environment_name="staging")
app_runners = client.apps.runners("my-app")# Optional filtersrecent = client.apps.runners("my-app", since=datetime.now() - timedelta(hours=1)) # last hourrunning_only = client.apps.runners("my-app", state=["running"]) # by state# List runners for an app in a specific environmentstaging_runners = client.apps.runners("my-app", environment_name="staging")
client.apps.rollout("my-app")# Force rolloutclient.apps.rollout("my-app", force=True)# Rollout in a specific environmentclient.apps.rollout("my-app", environment_name="staging")
from fal.sdk import KeyScope# ADMIN keys can manage resources; API keys are limited to app invocation.key_id, key_secret = client.keys.create( scope=KeyScope.ADMIN, # or KeyScope.API description="CI deploy key",)print(f"Store securely: {key_id}:{key_secret}") # secret shown only once
client.secrets.set("MY_API_TOKEN", "s3cr3t-value")# Set secret in a specific environmentclient.secrets.set("MY_API_TOKEN", "staging-value", environment_name="staging")
secrets = client.secrets.list()for secret in secrets: print(secret.name, secret.created_at, secret.environment_name)# List secrets for a specific environmentstaging_secrets = client.secrets.list(environment_name="staging")
Programmatic equivalent of fal deploy. If app_ref is omitted, discovery behavior matches the CLI (e.g., pyproject.toml).
# Auto-discoverclient.deploy()# Deploy from a file pathclient.deploy("path/to/myfile.py")# Deploy a specific class in a fileclient.deploy("path/to/myfile.py::MyApp")# Deploy by existing app nameclient.deploy("my-app")# With options mirroring CLI flagsclient.deploy( app_ref="path/to/myfile.py::MyApp", app_name="myapp", auth="public", # "private" | "public" strategy="rolling", # "recreate" | "rolling" reset_scale=True, # use previous scaling if False environment_name="staging", # target environment)