There are two ways to configure the ElevenLabs provider: through environment variables, which require no PHP code at all, or through an explicit configuration array passed toDocumentation 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.
ElevenLabs::create(). Both approaches produce an ElevenLabsProvider instance backed by an ElevenLabsOptions value object that carries the resolved settings for the lifetime of that provider.
Environment Variable Configuration
The simplest path is to setELEVENLABS_API_KEY in your environment. The provider reads it automatically the first time any static method is called on the ElevenLabs facade:
ELEVENLABS_BASE_URL takes effect only when no baseUrl key is provided in the configuration array. An explicit baseUrl passed to ElevenLabs::create() always takes precedence.
Explicit Configuration
CallElevenLabs::create() with a configuration array to supply options directly in PHP. This is the right approach when you are managing secrets through a vault, a DI container, or when you need to configure multiple providers with different keys:
ElevenLabs::create() returns the new ElevenLabsProvider instance and simultaneously registers it as the static default, so subsequent calls to the ElevenLabs:: facade methods will use this configuration.
Configuration Keys
Your ElevenLabs API key. If omitted, the provider falls back to the
ELEVENLABS_API_KEY environment variable. An exception is thrown at provider construction time if neither source supplies a value.The base URL for all API requests. Defaults to
https://api.elevenlabs.io/v1. Trailing slashes are stripped automatically. If omitted, the provider checks ELEVENLABS_BASE_URL before using the default. Useful for routing requests through a proxy or a local mock server during testing.A key-value map of additional HTTP headers to include on every request. These are merged with the authentication header. Any key present in
headers will override a header of the same name that the provider would otherwise set, with the exception that xi-api-key is always set from apiKey first and your custom headers are applied on top.How Authentication Headers Are Built
Every outbound request carries the headers produced byElevenLabsOptions::authHeaders(). The method sets xi-api-key to your resolved API key and then merges your custom headers array on top using array_replace, so custom headers always win on key conflicts:
Using a Proxy or Custom Endpoint
To route all ElevenLabs traffic through a proxy or a staging endpoint, setbaseUrl explicitly:
Resetting the Static Facade
ElevenLabs::reset() clears the static default provider, forcing the next call to the facade to construct a fresh instance. This is primarily useful in tests where you want to ensure configuration changes are fully isolated between test cases:
ElevenLabs::reset() only affects the static facade. ElevenLabsProvider instances you hold directly are unaffected.Configuration Reference
| Source | Key / Variable | Priority |
|---|---|---|
ElevenLabs::create() array | apiKey | Highest |
| Environment variable | ELEVENLABS_API_KEY | Fallback for apiKey |
ElevenLabs::create() array | baseUrl | Highest |
| Environment variable | ELEVENLABS_BASE_URL | Fallback for baseUrl |
| Built-in default | https://api.elevenlabs.io/v1 | Lowest |
