Skip to main content
from fal.api import (
    SyncServerlessClient,
    AppsNamespace,
    RunnersNamespace,
    KeysNamespace,
    SecretsNamespace,
)

Classes

SyncServerlessClient

class fal.api.SyncServerlessClient
Synchronous Python client for fal Serverless. Manage apps, runners, and deployments programmatically. The namespaces and methods mirror the CLI so you can automate the same workflows from Python. Example:
from fal.api import SyncServerlessClient

client = SyncServerlessClient()

# List apps
apps = client.apps.list()

# Scale an app
client.apps.scale("my-app", max_concurrency=10)

# Deploy
client.deploy("path/to/myfile.py::MyApp")
Namespaces:
  • client.apps.* - corresponds to fal apps ...
  • client.runners.* - corresponds to fal runners ...
  • client.keys.* - corresponds to fal keys ...
  • client.secrets.* - corresponds to fal secrets ...
  • client.deploy() - corresponds to fal deploy ...

Constructor Parameters

NameTypeDefaultDescription
hostOptional[str]NoneOptional. Override API host.
api_keyOptional[str]NoneOptional. If omitted, read from env/profile.
profileOptional[str]NoneOptional. Named profile to use.
teamOptional[str]NoneOptional. Team context for runner operations.

Class Variables

NameTypeDefaultDescription
hostOptional[str]None-
api_keyOptional[str]None-
profileOptional[str]None-
teamOptional[str]None-

Properties

NameTypeDescription
_credentialsCredentials-
_grpc_hoststr-
_rest_urlstr-

Methods

deploy

def deploy(self, *args, **kwargs)
Deploy an application. Corresponds to fal deploy. If app_ref is omitted, discovery behavior matches the CLI (e.g., uses pyproject.toml).Example:
# Auto-discover from pyproject.toml
client.deploy()

# Deploy from a file path
client.deploy("path/to/myfile.py")

# Deploy a specific class
client.deploy("path/to/myfile.py::MyApp")

# With options
client.deploy(
    app_ref="path/to/myfile.py::MyApp",
    app_name="myapp",
    auth="public",
    strategy="rolling",
)
ParameterTypeDefaultDescription
args---
kwargs---

AppsNamespace

class fal.api.AppsNamespace
Namespace for app management operations. Corresponds to fal apps ... CLI commands. Accessed via client.apps. Example:
from fal.api import SyncServerlessClient

client = SyncServerlessClient()
apps = client.apps.list()
client.apps.scale("my-app", max_concurrency=10)

Constructor Parameters

NameTypeDefaultDescription
clientSyncServerlessClient--

Methods

list

def list(self, *, filter: 'str | None' = None) -> 'List[AliasInfo]'
List all applications. Corresponds to fal apps list.Example:
apps = client.apps.list()
filtered = client.apps.list(filter="stable")
ParameterTypeDefaultDescription
filterstr | NoneNoneOptional app name filter string.
Returns: list[AliasInfo]

rollout

def rollout(self, app_name: 'str', *, force: 'bool' = False) -> 'None'
ParameterTypeDefaultDescription
app_namestr--
forceboolFalse-
Returns: NoneType

runners

def runners(self, app_name: 'str', *, since=None, state: 'List[str] | None' = None) -> 'List[RunnerInfo]'
List runners for a specific app. Corresponds to fal apps runners \<app\>.Example:
from datetime import datetime, timedelta

runners = client.apps.runners("my-app")
recent = client.apps.runners("my-app", since=datetime.now() - timedelta(hours=1))
running = client.apps.runners("my-app", state=["running"])
ParameterTypeDefaultDescription
app_namestr-Name of the application.
since-NoneOnly return runners started after this datetime.
stateOptional[list[str]]NoneFilter by runner state (e.g., [“running”]).
Returns: list[RunnerInfo]

scale

def scale(self, app_name: 'str', *, keep_alive: 'int | None' = None, max_multiplexing: 'int | None' = None, max_concurrency: 'int | None' = None, min_concurrency: 'int | None' = None, concurrency_buffer: 'int | None' = None, concurrency_buffer_perc: 'int | None' = None, scaling_delay: 'int | None' = None, request_timeout: 'int | None' = None, startup_timeout: 'int | None' = None, machine_types: 'List[str] | None' = None, regions: 'List[str] | None' = None) -> 'apps_api.AliasInfo'
Adjust scaling settings for an application. Corresponds to fal apps scale. Any omitted option keeps the current value.Example:
client.apps.scale(
    "my-app",
    keep_alive=300,
    max_concurrency=10,
    min_concurrency=1,
    machine_types=["GPU-H100", "GPU-H200"],
)
ParameterTypeDefaultDescription
app_namestr-Name of the application.
keep_aliveint | NoneNoneKeep-alive time in seconds.
max_multiplexingint | NoneNoneMaximum request multiplexing.
max_concurrencyint | NoneNoneMaximum concurrent runners.
min_concurrencyint | NoneNoneMinimum concurrent runners.
concurrency_bufferint | NoneNone-
concurrency_buffer_percint | NoneNone-
scaling_delayint | NoneNone-
request_timeoutint | NoneNoneRequest timeout in seconds.
startup_timeoutint | NoneNoneStartup timeout in seconds.
machine_typesOptional[list[str]]NoneList of allowed machine types (e.g., [“GPU-H100”]).
regionsOptional[list[str]]NoneList of allowed regions (e.g., [“us-east-1”]).
Returns: AliasInfo

RunnersNamespace

class fal.api.RunnersNamespace
Namespace for runner management operations. Corresponds to fal runners ... CLI commands. Accessed via client.runners. Example:
from fal.api import SyncServerlessClient

client = SyncServerlessClient()
runners = client.runners.list()
client.runners.stop("runner-id")

Constructor Parameters

NameTypeDefaultDescription
clientSyncServerlessClient--

Methods

kill

def kill(self, runner_id: 'str') -> 'None'
Forcefully kill a runner.
ParameterTypeDefaultDescription
runner_idstr-The ID of the runner to kill.
Returns: NoneType

list

def list(self, *, since=None) -> 'List[RunnerInfo]'
List all runners. Corresponds to fal runners list.Example:
from datetime import datetime, timedelta

all_runners = client.runners.list()
recent = client.runners.list(since=datetime.now() - timedelta(minutes=10))
ParameterTypeDefaultDescription
since-NoneOnly return runners started after this datetime.
Returns: list[RunnerInfo]

stop

def stop(self, runner_id: 'str') -> 'None'
Gracefully stop a runner.
ParameterTypeDefaultDescription
runner_idstr-The ID of the runner to stop.
Returns: NoneType

KeysNamespace

class fal.api.KeysNamespace
Namespace for API key management. Corresponds to fal keys ... CLI commands. Accessed via client.keys. Example:
from fal.api import SyncServerlessClient

client = SyncServerlessClient()
keys = client.keys.list()
key_id, key_secret = client.keys.create(scope="admin")

Constructor Parameters

NameTypeDefaultDescription
clientSyncServerlessClient--

Methods

create

def create(self, *, scope: 'KeyScope', description: 'str | None' = None) -> 'tuple[str, str]'
Create a new API key.
ParameterTypeDefaultDescription
scopeKeyScope-Key scope (e.g., “admin”).
descriptionstr | NoneNoneOptional description for the key.
Returns: tuple[str, str]

list

def list(self) -> 'List[UserKeyInfo]'
List all API keys.Returns: list[UserKeyInfo]

revoke

def revoke(self, key_id: 'str') -> 'None'
Revoke an API key.
ParameterTypeDefaultDescription
key_idstr-The ID of the key to revoke.
Returns: NoneType

SecretsNamespace

class fal.api.SecretsNamespace
Namespace for secrets management. Corresponds to fal secrets ... CLI commands. Accessed via client.secrets. Example:
from fal.api import SyncServerlessClient

client = SyncServerlessClient()
client.secrets.set("API_KEY", "my-secret-value")
secrets = client.secrets.list()

Constructor Parameters

NameTypeDefaultDescription
clientSyncServerlessClient--

Methods

list

def list(self) -> 'List[ServerlessSecret]'
List all secrets (names only, not values).Returns: list[ServerlessSecret]

set

def set(self, name: 'str', value: 'str') -> 'None'
Set a secret value.
ParameterTypeDefaultDescription
namestr-Name of the secret.
valuestr-Value to store.
Returns: NoneType

unset

def unset(self, name: 'str') -> 'None'
Delete a secret.
ParameterTypeDefaultDescription
namestr-Name of the secret to delete.
Returns: NoneType