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.

Running composer require aisdk/elevenlabs installs the ElevenLabs provider and its only production dependency, aisdk/core. The core package provides the shared Generate, Live, Content, and contract layer that all PHP AI SDK providers build on. No other runtime dependencies are required for speech generation, batch transcription, or the media service extensions.
Requirements: PHP ^8.3 and aisdk/core ^0.8.0. The package is published on Packagist as aisdk/elevenlabs.

Installation Steps

1

Install the package

Add aisdk/elevenlabs to your project using Composer:
composer require aisdk/elevenlabs
This installs the provider and aisdk/core. All speech, transcription, and media service capabilities are available immediately after this step.
2

Set your API key

The simplest configuration is a single environment variable. Export it in your shell, add it to your .env file, or inject it through your host’s secrets management:
export ELEVENLABS_API_KEY=xi-...
The provider reads ELEVENLABS_API_KEY automatically. No further PHP configuration is required if the environment variable is present when the application boots.
You can also pass the key directly in code using ElevenLabs::create(['apiKey' => 'xi-...']). See the Configuration page for all available options.
3

Install the WebSocket transport (optional)

Realtime transcription via Live::transcribe() requires a WebSocket transport. Install the ready-made aisdk/transport package to get one:
composer require aisdk/transport
Once installed, pass Transport::auto() when connecting a realtime session:
use AiSdk\ElevenLabs;
use AiSdk\Live;
use AiSdk\Live\TranscriptCompleted;
use AiSdk\Live\TranscriptUpdate;
use AiSdk\Transport;

$session = Live::transcribe()
    ->model(ElevenLabs::model('scribe_v2_realtime'))
    ->language('en')
    ->audioFormat('pcm_16000')
    ->connect(Transport::auto());

$session->sendAudio($pcmBytes);
$session->commitAudio();

foreach ($session->events() as $event) {
    if ($event instanceof TranscriptUpdate) {
        echo "\r{$event->text}";
    }

    if ($event instanceof TranscriptCompleted) {
        echo "\n{$event->text}\n";
    }
}
aisdk/transport is optional. You can pass any application transport that implements AiSdk\Live\Contracts\TransportInterface instead. Provider event encoding and normalization always come from aisdk/elevenlabs regardless of which transport you use.

Requirements Summary

RequirementVersion
PHP^8.3
aisdk/core^0.8.0
aisdk/transportOptional — realtime transcription only

Verifying the Installation

After installation, confirm everything is wired up by resolving a model reference. This exercises the autoloader and the environment-variable lookup without making a network request:
use AiSdk\ElevenLabs;

$model = ElevenLabs::model('eleven_flash_v2_5');

echo $model->id(); // eleven_flash_v2_5
If ELEVENLABS_API_KEY is not set and you have not called ElevenLabs::create() with an explicit key, the SDK will throw an exception at this point, which is the right time to discover a missing key rather than at the first actual API call.

Build docs developers (and LLMs) love