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:
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:
If no errors appear, the installation was successful.
3

Install Optional Dependencies

For audio playback functionality, install the optional PyAudio dependency:
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:
Install python-dotenv to load environment variables:

Installation Options

Using pip

The standard installation method:

Using pip with specific version

Install a specific version of the SDK:

Using pip with PyAudio

Install with audio playback support:

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:

Troubleshooting

PyAudio Installation Issues

If you encounter issues installing PyAudio:
Install PortAudio first using Homebrew:

Permission Errors

If you get permission errors, try installing with the --user flag:
For a clean installation, use a virtual environment:

Next Steps

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