Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/phpaisdk/fal/llms.txt

Use this file to discover all available pages before exploring further.

Fal (class AiSdk\Fal) is the top-level static entry point. It manages a singleton FalProvider instance so you do not need to construct providers manually across your application.

Fal::create()

Creates a new FalProvider from the given config array, sets it as the singleton default, and returns it.
public static function create(array $config = []): FalProvider
config
array
default:"[]"
Optional associative configuration array. Accepted keys:
return
FalProvider
The newly created FalProvider instance. This instance is also stored as the singleton returned by future Fal::default() calls.
$provider = Fal::create([
    'apiKey'  => getenv('FAL_API_KEY'),
    'baseUrl' => 'https://fal.run',
]);

Fal::default()

Returns the current singleton FalProvider, creating one from environment variables if none exists yet.
public static function default(): FalProvider
If no provider has been created yet (i.e. Fal::create() has not been called), the singleton is lazily initialised by calling Fal::create() with an empty config array and resolving credentials from the environment.
return
FalProvider
The current singleton FalProvider instance.
$provider = Fal::default();

Fal::model()

Delegates to Fal::default()->model($modelId) and returns the appropriate model instance based on usage context.
public static function model(string $modelId): Model
modelId
string
required
The fal.ai route segment that identifies the model, e.g. fal-ai/flux/schnell.
return
Model
A Model instance resolved from the singleton FalProvider.
$model = Fal::model('fal-ai/flux/schnell');
Fal::model() is a shorthand for Fal::default()->model(). The correct way to use a model is by passing the result to a generation call such as Generate::image()->model(Fal::model('fal-ai/flux/schnell')). See FalProvider for details on the provider internals.

Fal::reset()

Clears the singleton instance. Useful in tests to reset state between test cases.
public static function reset(): void
After calling reset(), the next call to Fal::default() or Fal::model() will create a fresh provider from the environment.
Fal::reset(); // singleton is now null

Build docs developers (and LLMs) love