Overview
The ElevenLabs Python SDK is the official Python library for the ElevenLabs API, installed with `pip install elevenlabs`. It wraps the HTTP API in an `ElevenLabs` client whose resources mirror the API reference: `text_to_speech.convert` and `text_to_speech.stream` for speech synthesis, `voices.search` and `voices.ivc.create` for listing and cloning voices, `models.list` for the available models, and more. An `AsyncElevenLabs` twin exposes the same calls for asyncio code, and helpers such as `play` and `stream` send audio straight to your speakers.
The library itself is MIT-licensed, but it is a client for a hosted service: every request needs an ElevenLabs API key, created in the ElevenLabs dashboard and passed either as `api_key=` or through the `ELEVENLABS_API_KEY` environment variable. Usage is billed against your ElevenLabs plan — there is a $0 Free plan as well as paid tiers — so the SDK is free to install but not free to run at volume.
Beyond one-shot synthesis, the SDK covers real-time voice work. The `conversational_ai` module runs ElevenAgents sessions with a local audio interface and lets you register sync or async Python functions as client tools the agent can call mid-conversation. The async-only Speech Engine opens a WebSocket server that ElevenLabs connects to: it receives user transcripts, lets you answer with any LLM (OpenAI, Anthropic and Google Gemini streams are auto-detected), cancels the in-flight reply when the user interrupts, and verifies that each incoming connection was signed by ElevenLabs. The library is generated with Fern from ElevenLabs' API definition, so code changes go through the vendor's generator rather than direct pull requests.
What it does
- Sync `ElevenLabs` and async `AsyncElevenLabs` clients covering the ElevenLabs HTTP API, including text-to-speech, voices and models
- Text-to-speech with a choice of models such as Eleven v3, Multilingual v2, Flash v2.5 and Turbo v2.5, selectable per call via `model_id`
- Real-time streaming: `text_to_speech.stream` yields audio bytes as they are generated, which you can play locally or process chunk by chunk
- Instant voice cloning from a few audio samples with `voices.ivc.create`, plus voice search and per-voice settings
- ElevenAgents conversations with a local audio interface and Python functions registered as client tools, with custom asyncio event loop support
- Speech Engine WebSocket server for server-side voice agents: bring any LLM, automatic interruption handling, and FastAPI/Starlette integration
Getting started
You need Python and an ElevenLabs account with an API key (a Free plan is available; usage beyond it is paid). These steps follow the SDK README and the ElevenLabs quickstart.
Install the SDK
Install the package from PyPI. The quickstart also installs python-dotenv to load the API key from a .env file.
pip install elevenlabs
pip install python-dotenvAdd your API key
Create an API key in the ElevenLabs dashboard (Settings → API keys) and store it in a .env file. Keep it secret — never ship it in client-side code.
ELEVENLABS_API_KEY=<your_api_key_here>Convert text to speech
Create a client and call text_to_speech.convert with a voice ID and model ID, then play the result. Local playback may prompt you to install MPV and/or ffmpeg.
from dotenv import load_dotenv
from elevenlabs.client import ElevenLabs
from elevenlabs.play import play
load_dotenv()
elevenlabs = ElevenLabs()
audio = elevenlabs.text_to_speech.convert(
text="The first move is what sets everything in motion.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_v3",
output_format="mp3_44100_128",
)
play(audio)Stream audio as it is generated
For lower time-to-first-audio, use text_to_speech.stream and either play the stream or handle the byte chunks yourself.
from elevenlabs import stream
from elevenlabs.client import ElevenLabs
elevenlabs = ElevenLabs(
api_key="YOUR_API_KEY",
)
audio_stream = elevenlabs.text_to_speech.stream(
text="This is a test",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_multilingual_v2"
)
# option 1: play the streamed audio locally
stream(audio_stream)
# option 2: process the audio bytes manually
for chunk in audio_stream:
if isinstance(chunk, bytes):
print(chunk)List voices or clone one
Search the voices available to your account, or create an instant voice clone from your own audio samples.
from elevenlabs.client import ElevenLabs
elevenlabs = ElevenLabs(
api_key="YOUR_API_KEY",
)
response = elevenlabs.voices.search()
print(response.voices)
voice = elevenlabs.voices.ivc.create(
name="Alex",
description="An old American male voice with a slight hoarseness in his throat. Perfect for news",
files=["./sample_0.mp3", "./sample_1.mp3", "./sample_2.mp3"],
)Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Adding ElevenLabs narration or character voices to a Python app, script or content pipeline
- Streaming synthesized speech with low latency into a chatbot, game or live assistant
- Building a voice agent in Python — either an ElevenAgents session with your own client tools, or a Speech Engine server that answers transcripts with the LLM of your choice
- Automating voice cloning and voice management against an ElevenLabs account from backend code
How ElevenLabs Python SDK compares
ElevenLabs Python SDK alongside other open-source media model apis tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| ElevenLabs Python SDK | ★ 3.2k | Official Python client for the ElevenLabs voice API: speech synthesis, streaming, voice cloning and voice agents |
| MiniMax MMX-CLI | ★ 2.2k | MiniMax's official command-line client for its generative platform — text, image, video, speech, vision and search as shell commands, installable as an agent skill. |
| MiniMax MCP | ★ 1.6k | MiniMax's official MCP server that lets Claude, Cursor and other MCP clients generate speech, clone and design voices, and create images and video through the MiniMax API. |
| ElevenLabs | — | AI voice platform with APIs for text-to-speech, voice cloning, dubbing, speech-to-text, and music generation across 70+ languages. |
| Deepgram | — | Enterprise voice AI APIs for real-time speech-to-text, text-to-speech, and voice agent orchestration. |
| AssemblyAI | — | Speech-to-text and speech understanding API that transcribes audio and extracts insights like sentiment and entities. |
| Stability AI | — | Generative media API for image, video, audio, and 3D generation, including Stable Diffusion and Stable Audio models. |
| Luma AI | — | Dream Machine API for generating video and images from text and image prompts. |