This guide walks through generating one asset for each supported modality — image, speech, transcription, and video — using theDocumentation 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.
aisdk/fal provider. By the end you will have working PHP snippets for all four and a clear picture of how the provider fits into the PHP AI SDK’s Generate::* fluent API.
Configure
Create a provider instance and pass your fal.ai API key:If
FAL_API_KEY is already set in your environment, you can omit the argument entirely. Both Fal::create() (with no arguments) and Fal::default() will read FAL_API_KEY automatically:Generate an image
Pass a fal model route to
Fal::model() and call Generate::image() with a prompt:$result->images is an array of ImageData objects. Each entry exposes a url pointing to the generated image hosted on fal’s CDN.Generate speech
Synthesize speech from text using a fal speech model. The provider fetches the audio bytes automatically and returns them in
$result->audio->data:Generate video (async)
Video generation is submitted to The
queue.fal.run and polled automatically until the job completes. Call Generate::video() exactly like the other modalities — the SDK handles queuing and polling behind the scenes:run() call blocks until the video is ready or the poll timeout is reached. Once complete, $result->video->url contains the URL of the rendered video.Language (chat/completions) and embedding modalities are not supported by the fal provider. Attempting to use them will throw a
NoSuchModelException.