Skip to main content

Documentation Index

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

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

The SoundEffects resource generates short audio clips from natural-language descriptions in a single call. Describe any real-world or imagined sound — an environment, an action, a texture — and the API returns a ready-to-use audio file. The resource is intentionally minimal: one method, one return type, no multi-step flow required.
use AiSdk\ElevenLabs;

$effect = ElevenLabs::soundEffects()->generate('A wooden door slowly creaking open.');
$effect->output->save(__DIR__.'/creak.mp3');

generate()

Produce a sound-effect audio clip from a descriptive text prompt.
$effect = ElevenLabs::soundEffects()->generate(
    'A wooden door slowly creaking open.',
    ['output_format' => 'mp3_44100_128'],
);

$effect->output->save(__DIR__.'/creak.mp3');
Internally, the prompt argument is sent to the ElevenLabs /sound-generation endpoint as the text field in the JSON request body. The output_format option is extracted and forwarded as a URL query parameter before the remaining options are serialised into the body.

Parameters

prompt
string
required
A natural-language description of the sound to generate. Mapped to the text key in the JSON request body. The more specific and vivid the description, the more accurate and consistent the output tends to be.
options
array
Optional generation controls.
output_format
string
Audio encoding for the returned file (e.g. mp3_44100_128, mp3_44100_64, pcm_44100). Defaults to mp3_44100_128. This value is extracted from the options array and forwarded as a URL query parameter before the remaining options are sent in the JSON body.
duration_seconds
float
Optional hint for the desired length of the sound effect in seconds. When omitted, ElevenLabs infers a suitable duration from the prompt.

Return value

AudioResult
object
output
AudioData
The generated audio. Call ->save($path) to write it to disk, or access ->data for the raw bytes and ->mimeType for the content type.

Prompt examples

The quality of the output is directly tied to the quality of the prompt. Short, vague prompts can work, but clear, specific descriptions consistently produce more usable results.
Include the material, the action, the environment, and any relevant acoustic detail in your prompt. A description like “a heavy oak door swinging open on rusty hinges in an empty stone corridor” gives the model far more to work with than just “door creak”.
$rain = ElevenLabs::soundEffects()->generate(
    'Heavy rainfall on a corrugated tin roof with occasional distant thunder.',
    ['duration_seconds' => 8.0],
);
$rain->output->save(__DIR__.'/rain.mp3');

Saving and using the result

generate() returns an AudioResult. The output property is an AudioData object with two access patterns:
1

Save to a file

$effect->output->save(__DIR__.'/effect.mp3');
Writes the audio bytes to the given path and returns the path string.
2

Access raw bytes

$bytes    = $effect->output->data;     // raw audio string
$mimeType = $effect->output->mimeType; // e.g. "audio/mpeg"
Use this when you need to stream the bytes directly to an HTTP response, store them in a database, or pass them to another library.

Build docs developers (and LLMs) love