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.
FalSpeechModel makes two HTTP calls on your behalf: first, a POST to {baseUrl}/{modelId} (defaulting to https://fal.run/{modelId}) to request speech synthesis and receive an audio URL from fal.ai; then, a GET to that URL to download the raw audio bytes. Both steps are handled automatically inside run() — your code receives a fully populated SpeechResponse with the audio data already fetched and ready to use.
Basic Usage
Request Parameters
The following fields are sent as JSON to the fal.ai endpoint:| Field | Type | Source | Description |
|---|---|---|---|
text | string | $request->input | The text to synthesize into speech. |
voice | string | $request->voice | The voice identifier to use for synthesis. |
$request->providerOptionsFor('fal') are merged into the body, allowing you to pass any model-specific parameters supported by the fal.ai endpoint.
Response
generate() returns a SpeechResponse with an audio property of type AudioData:
data(string) — the raw audio bytes, downloaded directly from the URL returned by fal.ai.mimeType(string) — taken fromaudio.content_typein the fal.ai response; defaults toaudio/mpegwhen the API omits it.
A
RuntimeException is thrown if fal.ai does not return a valid audio URL in the synthesis response. This can occur if the model rejects the input text or if the request payload is malformed.Saving Audio
Theaudio->data property contains the raw bytes of the audio file and can be written directly to disk or streamed to the client:
Provider Options
Pass model-specific parameters usingproviderOptions():
