PHPackages                             aisdk/elevenlabs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. aisdk/elevenlabs

ActiveLibrary

aisdk/elevenlabs
================

ElevenLabs generative media provider for the PHP AI SDK.

v0.8.0(1mo ago)03MITPHPPHP ^8.3CI passing

Since Jul 15Pushed 1mo agoCompare

[ Source](https://github.com/phpaisdk/elevenlabs)[ Packagist](https://packagist.org/packages/aisdk/elevenlabs)[ Docs](https://github.com/phpaisdk/elevenlabs)[ RSS](/packages/aisdk-elevenlabs/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

aisdk/elevenlabs
================

[](#aisdkelevenlabs)

[![GitHub Workflow Status](https://camo.githubusercontent.com/a1fb62b6925a5f3c2e0ec8b460020e0d9fd85272b74663bbb70f44a2352667f2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706870616973646b2f656c6576656e6c6162732f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473)](https://github.com/phpaisdk/elevenlabs/actions)[![Total Downloads](https://camo.githubusercontent.com/1fa4497739de603427165254c4a3a4ef242108b2a87514011378d8ccc87511d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616973646b2f656c6576656e6c616273)](https://packagist.org/packages/aisdk/elevenlabs)[![Latest Version](https://camo.githubusercontent.com/4b9c42fad0bd576a5be5019deb6387945fab224041fb2a93e1e667d60d1d7df4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616973646b2f656c6576656e6c616273)](https://packagist.org/packages/aisdk/elevenlabs)[![License](https://camo.githubusercontent.com/19d8b423bc5c80913dfd8e5750980122c54afb9de9ecf98001188a92390375ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616973646b2f656c6576656e6c616273)](https://packagist.org/packages/aisdk/elevenlabs)[![Why PHP in 2026](https://camo.githubusercontent.com/d2b9305e630caf7daae4ca023de39ece0b885c37461629d42961533f00868b76/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5768795f5048502d696e5f323032362d3741383645383f7374796c653d666c61742d737175617265266c6162656c436f6c6f723d313831383162)](https://whyphp.dev)

---

Official ElevenLabs generative-media provider for the PHP AI SDK.

Installation
------------

[](#installation)

```
composer require aisdk/elevenlabs
```

Configuration
-------------

[](#configuration)

Set `ELEVENLABS_API_KEY`, or configure the provider directly:

```
use AiSdk\ElevenLabs;

ElevenLabs::create([
    'apiKey' => 'xi-...',
    'baseUrl' => 'https://api.elevenlabs.io/v1',
    'headers' => ['X-Custom-Header' => 'value'],
]);
```

`ELEVENLABS_BASE_URL` overrides the default base URL when no `baseUrl` option is supplied.

Supported SDK Capabilities
--------------------------

[](#supported-sdk-capabilities)

CapabilitySupportSpeech generationNativeTranscriptionNativeRealtime transcriptionNative through `Live::transcribe()`Text, image, embeddings, videoNot provided by this packageModel IDs are opaque. Use the ElevenLabs model identifier appropriate for the operation, such as `eleven_flash_v2_5`, `eleven_v3`, or `scribe_v2`.

Provider-owned extensions cover the direct ElevenLabs creative-media APIs that do not belong in core:

ExtensionSurfaceVoice changer and isolationAudio-to-audio transformsVoice designDesign previews, remix a voice, and save a selected generated previewMusicCompose, composition plans, detailed output, video-to-music, upload, and stem separationSound effects and dialogueText-to-audio generation, including dialogue timestampsDubbingCreate a dub, inspect its status, and retrieve dubbed media or transcriptsForced alignmentAlign supplied audio and transcript textThese extensions are available from either the configured provider instance or the static facade:

```
$elevenLabs = ElevenLabs::create(['apiKey' => 'xi-...']);

$music = $elevenLabs->music()->compose('A warm acoustic intro.');
$sameResource = ElevenLabs::music();
```

Speech Generation
-----------------

[](#speech-generation)

Voice IDs are an ElevenLabs requirement, so provide one using the portable `voice()` method.

```
use AiSdk\ElevenLabs;
use AiSdk\Generate;

$result = Generate::speech('Welcome to the show.')
    ->model(ElevenLabs::model('eleven_flash_v2_5'))
    ->voice('JBFqnCBsd6RMkjVDRZzb')
    ->format('mp3')
    ->providerOptions('elevenlabs', [
        'voice_settings' => [
            'stability' => 0.5,
            'similarity_boost' => 0.75,
        ],
    ])
    ->run();

$result->output->save(__DIR__.'/speech.mp3');
```

Use `providerOptions('elevenlabs', ...)` for documented ElevenLabs request fields such as `apply_text_normalization`, `language_code`, `seed`, and pronunciation dictionaries. Set `output_format` there when an ElevenLabs-specific output format is needed.

The adapter sends `output_format`, `enable_logging`, and the deprecated `optimize_streaming_latency` field as query parameters, while keeping voice settings and generation controls in the JSON request body, matching the ElevenLabs API contract.

Transcription
-------------

[](#transcription)

```
use AiSdk\Content;
use AiSdk\ElevenLabs;
use AiSdk\Generate;

$result = Generate::transcription(Content::audio(__DIR__.'/meeting.mp3'))
    ->model(ElevenLabs::model('scribe_v2'))
    ->providerOptions('elevenlabs', [
        'language_code' => 'en',
        'diarize' => true,
    ])
    ->run();

echo $result->output->text;
```

Realtime Transcription
----------------------

[](#realtime-transcription)

Scribe v2 Realtime uses the core Live API. Install `aisdk/transport` for the ready-made WebSocket transport:

```
composer require aisdk/transport
```

```
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')
    ->providerOptions('elevenlabs', [
        'commit_strategy' => 'manual',
        'include_timestamps' => true,
    ])
    ->connect(Transport::auto());

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

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

    if ($event instanceof TranscriptCompleted) {
        echo "\n{$event->text}\n";
    }
}
```

`aisdk/transport` is optional. Without it, pass any application transport implementing `AiSdk\Live\Contracts\TransportInterface`; provider event encoding and normalization still come from this package.

For a browser connection, create a short-lived single-use token on your server and return only its value to your authenticated client:

```
$secret = Live::transcribe()
    ->model(ElevenLabs::model('scribe_v2_realtime'))
    ->clientSecret();

return ['token' => $secret->value, 'expires_at' => $secret->expiresAt];
```

The browser connects natively to ElevenLabs using that token. Never expose the workspace API key to client-side code.

```
const { token } = await fetch('/api/elevenlabs/scribe-token').then(response => response.json());
const query = new URLSearchParams({
    model_id: 'scribe_v2_realtime',
    audio_format: 'pcm_16000',
    commit_strategy: 'vad',
    token,
});
const socket = new WebSocket(`wss://api.elevenlabs.io/v1/speech-to-text/realtime?${query}`);

socket.addEventListener('message', ({ data }) => {
    const event = JSON.parse(data);

    if (event.message_type === 'partial_transcript') {
        console.log('Partial:', event.text);
    }

    if (event.message_type === 'committed_transcript') {
        console.log('Final:', event.text);
    }
});
```

When `include_timestamps=true`, the ordinary committed transcript is normalized as `TranscriptCompleted`; the following `committed_transcript_with_timestamps` message remains available as a raw `ProviderEvent`, preserving ElevenLabs word metadata without duplicating the portable completion event.

ElevenLabs Media Services
-------------------------

[](#elevenlabs-media-services)

These capabilities are intentionally provider-owned instead of being added to `aisdk/core`.

### Voice Changer

[](#voice-changer)

```
$result = ElevenLabs::voiceChanger()->convert(
    voiceId: 'JBFqnCBsd6RMkjVDRZzb',
    audio: Content::audio(__DIR__.'/performance.wav'),
    options: [
        'model_id' => 'eleven_multilingual_sts_v2',
        'remove_background_noise' => true,
        'output_format' => 'wav_44100',
    ],
);

$result->output->save(__DIR__.'/changed.wav');
```

### Voice Isolator

[](#voice-isolator)

```
$result = ElevenLabs::voiceIsolator()->isolate(
    Content::audio(__DIR__.'/noisy-interview.mp3'),
);

$result->output->save(__DIR__.'/clean.mp3');
```

### Music and Sound Effects

[](#music-and-sound-effects)

```
$music = ElevenLabs::music()->compose('Warm acoustic guitar intro with gentle rain.', [
    'model_id' => 'music_v1',
    'music_length_ms' => 30_000,
]);

$effect = ElevenLabs::soundEffects()->generate('A wooden door slowly creaking open.');
```

Music also supports composition plans and detailed metadata without opting into an HTTP streaming variant:

```
$plan = ElevenLabs::music()->plan('A tense cinematic cue with a quiet ending.', [
    'model_id' => 'music_v2',
    'music_length_ms' => 30_000,
]);

$track = ElevenLabs::music()->composeFromPlan($plan, [
    'model_id' => 'music_v2',
    'output_format' => 'mp3_48000_192',
]);

$detailed = ElevenLabs::music()->composeDetailed('A bright synth-pop theme.', [
    'model_id' => 'music_v2',
    'with_timestamps' => true,
]);

echo $detailed->songId;
$detailed->output->save(__DIR__.'/theme.mp3');
```

Direct music transforms use typed `Content` inputs:

```
$soundtrack = ElevenLabs::music()->videoToMusic([
    Content::video(__DIR__.'/opening.mp4'),
    Content::video(__DIR__.'/closing.mp4'),
], [
    'description' => 'Cinematic, restrained, then uplifting.',
    'tags' => ['cinematic', 'orchestral'],
    'model_id' => 'music_v2',
]);

$stems = ElevenLabs::music()->separateStems(
    Content::audio(__DIR__.'/song.mp3'),
    ['stem_variation_id' => 'six_stems_v1'],
);

$stems->save(__DIR__.'/stems.zip');
```

`music()->upload()` uploads source audio for ElevenLabs composition-plan and inpainting workflows and returns its typed song ID, optional plan, and optional word timestamps.

### Text to Dialogue

[](#text-to-dialogue)

```
$dialogue = ElevenLabs::dialogue()->create([
    ['text' => '[giggling] Knock knock.', 'voice_id' => 'JBFqnCBsd6RMkjVDRZzb'],
    ['text' => '[curious] Who is there?', 'voice_id' => 'Aw4FAjKCGjjNkVhN1Xmq'],
], ['model_id' => 'eleven_v3']);
```

Use `withTimestamps()` when character alignment and per-voice segments are needed:

```
$dialogue = ElevenLabs::dialogue()->withTimestamps([
    ['text' => 'Ready?', 'voice_id' => 'JBFqnCBsd6RMkjVDRZzb'],
    ['text' => 'Ready.', 'voice_id' => 'Aw4FAjKCGjjNkVhN1Xmq'],
]);

$dialogue->output->save(__DIR__.'/dialogue.mp3');
foreach ($dialogue->voiceSegments as $segment) {
    echo "{$segment->voiceId}: {$segment->start} - {$segment->end}\n";
}
```

### Voice Design and Remixing

[](#voice-design-and-remixing)

Voice design is a two-step generation flow: generate previews, then save the selected preview as a usable voice.

```
$design = ElevenLabs::voiceDesign()->design(
    'A warm, expressive documentary narrator with measured pacing.',
    [
        'model_id' => 'eleven_ttv_v3',
        'auto_generate_text' => true,
    ],
);

$preview = $design->previews[0];
$preview->audio->save(__DIR__.'/voice-preview.mp3');

$voice = ElevenLabs::voiceDesign()->create(
    generatedVoiceId: $preview->generatedVoiceId,
    name: 'Documentary narrator',
    description: 'A warm, expressive documentary narrator with measured pacing.',
);

echo $voice->id;
```

To transform an eligible existing voice instead, call `voiceDesign()->remix($voiceId, $description, $options)` and save one of its generated previews in the same way.

### Dubbing

[](#dubbing)

Create a dub from local audio/video or from a URL-backed `Content` value, inspect the asynchronous job, then retrieve the output:

```
$job = ElevenLabs::dubbing()->create(
    Content::video(__DIR__.'/interview.mp4'),
    targetLanguage: 'es',
    options: ['source_lang' => 'en'],
);

$status = ElevenLabs::dubbing()->status($job->id);

if ($status->status === 'dubbed') {
    ElevenLabs::dubbing()
        ->output($job->id, 'es')
        ->save(__DIR__.'/interview-es.mp4');

    $subtitles = ElevenLabs::dubbing()->transcript($job->id, 'es', 'srt');
    file_put_contents(__DIR__.'/interview-es.srt', $subtitles->content ?? '');
}
```

### Forced Alignment

[](#forced-alignment)

```
$alignment = ElevenLabs::forcedAlignment()->create(
    Content::audio(__DIR__.'/narration.wav'),
    'The exact transcript spoken in the recording.',
);

foreach ($alignment->words as $word) {
    echo "{$word->text}: {$word->start} - {$word->end}\n";
}
```

Scope
-----

[](#scope)

This package deliberately stays on the direct generative/media surface.

IncludedDeliberately excludedTTS, batch STT, and realtime ScribeElevenAgents and its telephony/runtime management APIsVoice changer, isolation, design, and remixingVoice-library browsing, cloning/training, and general voice CRUDMusic generation and direct music transformsMusic finetune, asset/history, and marketplace managementSound effects and text-to-dialogueStudio, Audio Native, Flows, and project/editor managementDubbing creation and result retrievalDubbing Studio resource editing, listing, and deletionForced alignmentAccount, workspace, API-key, billing, analytics, and administrative APIsSaving a generated voice preview is included because it is the required second step of the Voice Design and Remix APIs. Pronunciation-dictionary management, AI-audio detection, human production services, and HTTP streaming variants of otherwise one-shot media endpoints are outside this package surface. Core realtime transcription remains fully supported through `Live::transcribe()`.

Testing
-------

[](#testing)

```
composer test:all
```

The default suite is fixture- and conformance-based. Credentialed Live network verification is separate and is not run by `composer test`.

Documentation
-------------

[](#documentation)

- [PHP AI SDK documentation](https://phpaisdk.com/docs)
- [ElevenLabs documentation](https://phpaisdk.com/docs/elevenlabs)

Community
---------

[](#community)

- [Contributing](https://github.com/phpaisdk/.github/blob/main/CONTRIBUTING.md)
- [Support](https://github.com/phpaisdk/.github/blob/main/SUPPORT.md)
- For private security reports, email .

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

47d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef29d1962da41e7526023f215cf844494e209b2fd163742084cb919a3b508021?d=identicon)[aisdk](/maintainers/aisdk)

---

Top Contributors

[![RanaMoizHaider](https://avatars.githubusercontent.com/u/58527494?v=4)](https://github.com/RanaMoizHaider "RanaMoizHaider (8 commits)")

---

Tags

aivoicemusicTranscriptionelevenlabsspeechaisdkdubbing

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aisdk-elevenlabs/health.svg)

```
[![Health](https://phpackages.com/badges/aisdk-elevenlabs/health.svg)](https://phpackages.com/packages/aisdk-elevenlabs)
```

###  Alternatives

[symfony/ai-platform

PHP library for interacting with AI platform provider.

541.8M429](/packages/symfony-ai-platform)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
