Get Started with ElevenLabs API

Convert text to natural-sounding speech with a few lines of Python code.
Prerequisites
- Python 3.7+
- An ElevenLabs account (free or paid)
- A text editor
Step 1: Create an API Key
Go to the ElevenLabs API Keys dashboard and create a new key.
Store it in a .env file in your project folder:
ELEVENLABS_API_KEY=your_api_key_here
Step 2: Install the SDK
pip install elevenlabs python-dotenv
To hear audio play automatically, you may need to install MPV and ffmpeg (the package will prompt you if needed).
Step 3: Create Your Script
Create example.py:
from dotenv import load_dotenv
from elevenlabs.client import ElevenLabs
from elevenlabs.play import play
import os
load_dotenv()
elevenlabs = ElevenLabs(api_key=os.getenv("ELEVENLABS_API_KEY"))
audio = elevenlabs.text_to_speech.convert(
text="The first move is what sets everything in motion.",
voice_id="JBFqnCBsd6RMkjVDRZzb",
model_id="eleven_multilingual_v2",
output_format="mp3_44100_128",
)
play(audio)
Parameters:
text: What to convert to speechvoice_id: Which voice to use (find in your dashboard)model_id: The AI model (useeleven_multilingual_v2)output_format: Audio quality (mp3_44100_128is standard)
Step 4: Run It
python example.py
You should hear the audio play through your speakers.
Troubleshooting
| Problem | Solution |
|---|---|
ModuleNotFoundError |
Run pip install elevenlabs python-dotenv |
ELEVENLABS_API_KEY not found |
Make sure .env is in the same folder as your script |
Invalid API key |
Create a new key in the dashboard and update .env |
| Audio doesn’t play | Save to a file: with open("output.mp3", "wb") as f: f.write(audio) |
Quick FAQ
How many API calls can I make?
Free tier accounts get 10,000 characters/month. Paid plans offer higher limits. Check the pricing page for details.
What languages are supported?
The
eleven_multilingual_v2model supports 29+ languages including English, Spanish, French, German, Chinese, Japanese, and more.Can I use this API commercially?
Yes, commercial use is allowed for both free and paid accounts. Check the terms of service for specific guidelines on your account type.
How do I find other available voices?
Browse available voices in your ElevenLabs dashboard. Click on each voice to hear samples and copy its voice ID for use in your scripts.

Written by
Marco Sansalone
Also in ElevenLabs Guide
Something Not Working? Tell Us What’s Wrong.
You'll be notified when the tutorial goes live and join our newsletter on AI tools and tutorials.
