Skip to main content

Classes

Audio

!!! abstract “Usage Documentation” Models A base class for creating Pydantic models.
Inherits from: File

Constructor Parameters

CompressedFile

!!! abstract “Usage Documentation” Models A base class for creating Pydantic models.
Inherits from: File

Constructor Parameters

Class Variables

Methods

glob

FalBaseModel

Base model for fal applications with field ordering, visibility control, and context binding for error reporting. Features:
  • FIELD_ORDERS: Control field order in JSON schema, useful for nested models.
  • Hidden(Field(…)): Mark fields as hidden from OpenAPI schema, useful for hidden params.
Example:
Inherits from: BaseModel

Constructor Parameters

Class Variables

File

!!! abstract “Usage Documentation” Models A base class for creating Pydantic models.
Inherits from: BaseModel

Constructor Parameters

Class Variables

Methods

as_bytes

Returns: bytes

from_bytes

Returns: File

from_bytes_async

Returns: File

from_path

Returns: File

from_path_async

Returns: File

save

Returns: Path

save_async

Returns: Path

Image

Represents an image file.
Inherits from: File

Constructor Parameters

Class Variables

Methods

from_bytes

Returns: Image

from_pil

to_pil

ImageSizeConstraints

Advisory limits on the image size a model can generate. Attach to an image_size field via :func:fal.toolkit.ImageSizeField to surface the model’s size envelope in the OpenAPI schema (under the x-fal extension), so clients and UIs can validate sizes before a request. These are documentation hints and are not enforced by the SDK.

Constructor Parameters

Class Variables

ImageValidationConfig

Limits applied to an input image. Surfaced in the schema (x-fal); the SDK does not enforce them.

Constructor Parameters

Class Variables

ImageValidationOptions

Validation options accepted by input-image helpers.
Inherits from: dict

Constructor Parameters

Class Variables

KVStore

A key-value store client for interacting with the FAL KV service.

Constructor Parameters

Properties

Methods

delete

Delete a value from the key-value store. The operation is idempotent and succeeds whether or not the key existed.Returns: NoneType

get

Retrieve a value from the key-value store.Returns: Optional[str]

set

Store a value in the key-value store.Returns: NoneType

Video

!!! abstract “Usage Documentation” Models A base class for creating Pydantic models.
Inherits from: File

Constructor Parameters

FalTookitException

Base exception for all toolkit exceptions
Inherits from: Exception

Constructor Parameters

FileUploadException

Raised when file upload fails
Inherits from: FalTookitException

Constructor Parameters

KVStoreException

Raised when KV store operation fails
Inherits from: FalTookitException

Constructor Parameters

DownloadError

Common base class for all non-exit exceptions.
Inherits from: Exception

Constructor Parameters


Functions

to_xfal

Return a config’s set (non-None) limits as the x-fal schema payload. Returns: dict[str, Any]

Hidden

Wrapper that marks a Field as hidden in the UI. The field MUST have a default or default_factory set since hidden fields cannot be required inputs in the UI. Usage: class Input(FalBaseModel): prompt: str = Field(…) hidden_flag: bool = Hidden(Field(default=False)) Returns: _T Raises:
  • ValueError: If field has no default or default_factory

get_image_size

Returns: ImageSize

clone_repository

Clones a Git repository from the specified HTTPS URL into a local directory. This function clones a Git repository from the specified HTTPS URL into a local directory. It can also checkout a specific commit if the commit_hash is provided. If a custom target_dir or repo_name is not specified, a predefined directory is used for the target directory, and the repository name is determined from the URL. Returns: Path

download_file

Downloads a file from the specified URL to the target directory. The function downloads the file from the given URL and saves it in the specified target directory, provided it is below the given filesize limit. If the downloaded response resolves to an existing local file whose content length matches the downloaded file, the existing file is kept. If the file needs to be downloaded or if an existing file’s content length does not match the expected length, the function proceeds to download and save the file. It ensures that the target directory exists and handles any errors that may occur during the download process, raising a DownloadError if necessary. Returns: Path Raises:
  • DownloadError: If an error occurs during the download process.

download_model_weights

Downloads model weights from the specified URL and saves them to a predefined directory. This function is specifically designed for downloading model weights and stores them in a predefined directory. It calls the download_file function with the provided URL and the target directory set to a pre-defined location for model weights. The downloaded model weights are saved in this directory, and the function returns the full path to the downloaded weights file. Returns: Path

get_gpu_type

Detect the GPU type using nvidia-smi. Example:
Returns: str

load_inductor_cache

Load PyTorch Inductor compilation cache from global storage. This function:
  1. Sets TORCHINDUCTOR_CACHE_DIR environment variable
  2. Looks for cached compiled kernels in GPU-specific global storage
  3. Unpacks the cache to local temporary directory
  4. Returns a hash of the unpacked directory for change detection
Example:
Returns: str

sync_inductor_cache

Sync updated PyTorch Inductor cache back to global storage. This function:
  1. Checks if the local cache has changed (by comparing hashes)
  2. If changed, creates a zip archive of the new cache
  3. Saves it to GPU-specific global storage
Example:
Returns: NoneType

synchronized_inductor_cache

Context manager to automatically load and sync PyTorch Inductor cache. This wraps load_inductor_cache and sync_inductor_cache for convenience. The cache is loaded on entry and synced on exit (even if an exception occurs). Example:
Returns: Iterator[]