Skip to main content

Prerequisites

Before installing the ElevenLabs Python SDK, ensure you have:
  • Python 3.8 or higher installed on your system
  • pip (Python package manager) installed
  • An ElevenLabs account and API key (sign up here)

Installation Steps

1

Install the SDK

Install the ElevenLabs Python SDK using pip:
pip install elevenlabs
This will install the latest stable version of the SDK along with all required dependencies.
2

Verify Installation

Verify the installation by importing the package in Python:
from elevenlabs.client import ElevenLabs
print("ElevenLabs SDK installed successfully!")
If no errors appear, the installation was successful.
3

Install Optional Dependencies

For audio playback functionality, install the optional PyAudio dependency:
pip install elevenlabs[pyaudio]
PyAudio is required if you want to use the play() function to hear generated audio directly in your application.
4

Set Up Environment Variables (Recommended)

Create a .env file in your project root to store your API key securely:
ELEVENLABS_API_KEY=your_api_key_here
Install python-dotenv to load environment variables:
pip install python-dotenv

Installation Options

Using pip

The standard installation method:
pip install elevenlabs

Using pip with specific version

Install a specific version of the SDK:
pip install elevenlabs==2.37.0

Using pip with PyAudio

Install with audio playback support:
pip install elevenlabs[pyaudio]

Dependencies

The ElevenLabs Python SDK includes the following core dependencies:
  • httpx (>= 0.21.2) - HTTP client for API requests
  • pydantic (>= 1.9.2) - Data validation
  • pydantic-core (>= 2.18.2) - Pydantic core functionality
  • requests (>= 2.20) - HTTP library
  • typing_extensions (>= 4.0.0) - Type hints support
  • websockets (>= 11.0) - WebSocket support for real-time features

Optional Dependencies

  • pyaudio (>= 0.2.14) - Audio playback functionality
All core dependencies are automatically installed when you install the SDK. You only need to manually install optional dependencies if you need their functionality.

Platform Support

The ElevenLabs Python SDK is compatible with:
  • Linux (all distributions)
  • macOS
  • Windows
  • POSIX-compliant systems

Upgrading the SDK

To upgrade to the latest version:
pip install --upgrade elevenlabs

Troubleshooting

PyAudio Installation Issues

If you encounter issues installing PyAudio:
Install PortAudio first using Homebrew:
brew install portaudio
pip install elevenlabs[pyaudio]

Permission Errors

If you get permission errors, try installing with the --user flag:
pip install --user elevenlabs
For a clean installation, use a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install elevenlabs

Next Steps

Now that you’ve installed the SDK, learn how to:

Build docs developers (and LLMs) love