Skip to main content

Overview

The ElevenLabs client class is the primary interface for interacting with the ElevenLabs API synchronously. You can instantiate multiple clients with different configurations that will propagate to all API methods.

Initialization

Parameters

str
Your ElevenLabs API key. If not provided, the client will attempt to read from the ELEVENLABS_API_KEY environment variable.
str
The base URL to use for requests from the client. Use this to override the default API endpoint.
ElevenLabsEnvironment
default:"ElevenLabsEnvironment.PRODUCTION"
The environment to use for requests from the client. Import with:
Dict[str, str]
Additional headers to send with every request.
float
default:"240"
The timeout to be used, in seconds, for requests. By default the timeout is 240 seconds, unless a custom httpx client is used, in which case this default is not enforced.
bool
default:"true"
Whether the default httpx client follows redirects or not. This is irrelevant if a custom httpx client is passed in.
httpx.Client
The httpx client to use for making requests. A preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

Properties

The client provides access to various API endpoints through properties:

history

Access to the History API for retrieving and managing generated audio history. Type: HistoryClient

text_to_speech

Access to the Text-to-Speech API for converting text to speech audio. Type: TextToSpeechClient

text_to_sound_effects

Access to the Text-to-Sound Effects API for generating sound effects from text descriptions. Type: TextToSoundEffectsClient

text_to_dialogue

Access to the Text-to-Dialogue API for creating multi-voice dialogues. Type: TextToDialogueClient

speech_to_speech

Access to the Speech-to-Speech API for voice conversion. Type: SpeechToSpeechClient

speech_to_text

Access to the Speech-to-Text API for transcribing audio to text. Type: SpeechToTextClient

text_to_voice

Access to the Text-to-Voice API for creating custom voices. Type: TextToVoiceClient

voices

Access to the Voices API for managing and retrieving voice models. Type: VoicesClient

models

Access to the Models API for retrieving available AI models. Type: ModelsClient

user

Access to the User API for managing user account information. Type: UserClient

usage

Access to the Usage API for tracking API usage and quotas. Type: UsageClient

samples

Access to the Samples API for managing voice samples. Type: SamplesClient

audio_isolation

Access to the Audio Isolation API for separating audio sources. Type: AudioIsolationClient

audio_native

Access to the Audio Native API for creating audio-native projects. Type: AudioNativeClient

dubbing

Access to the Dubbing API for video and audio dubbing. Type: DubbingClient

studio

Access to the Studio API for managing studio projects. Type: StudioClient

pronunciation_dictionaries

Access to the Pronunciation Dictionaries API for managing custom pronunciations. Type: PronunciationDictionariesClient

service_accounts

Access to the Service Accounts API for managing service accounts. Type: ServiceAccountsClient

webhooks

Access to the Webhooks API for managing webhook subscriptions. Type: WebhooksClient

forced_alignment

Access to the Forced Alignment API for audio-text alignment. Type: ForcedAlignmentClient

conversational_ai

Access to the Conversational AI API for building conversational agents. Type: ConversationalAiClient

music

Access to the Music API for generating AI music. Type: MusicClient

tokens

Access to the Tokens API for managing authentication tokens. Type: TokensClient

workspace

Access to the Workspace API for managing workspace settings. Type: WorkspaceClient

with_raw_response

Retrieves a raw implementation of this client that returns raw HTTP responses instead of parsed data. Type: RawBaseElevenLabs

Example Usage

Basic Client Initialization

Custom Configuration

Using Environment Variables

Accessing API Endpoints

Using Custom HTTP Client