ElevenLabs API Key: How to Get One and Use It (2026)
Unicorn API Team · · 10 min read
An ElevenLabs API key is the secret string that lets your code call ElevenLabs text to speech, voice cloning and dialogue features without logging in to the website. You create it in the ElevenLabs dashboard, keep it on your server, and send it with every request. This guide shows where to find it, how to use it in code, how to keep it safe, what to do when it stops working, and how to reach the same ElevenLabs voices with a single key that also covers other models.
What is an ElevenLabs API key?
An API key is a long random token that identifies you to a service. When your program sends a request, the key tells the server who is asking and whose quota to charge. Anyone holding the key can spend your credits, which is why it should be treated like a password.
ElevenLabs is a voice AI company that builds speech synthesis models, the technology that turns written text into natural-sounding spoken audio. Its web app, at elevenlabs.io, lets you type text and download audio by hand. The API does the same thing from code, which is what you want when you narrate hundreds of articles, voice a game, build a support bot, or add speech to an app.
A few points about how the ElevenLabs API key works in practice:
- It travels in a custom header. ElevenLabs expects the key in a header called
xi-api-key, not in the more commonAuthorization: Bearerheader. Mixing these up is the single most frequent cause of authentication errors. - It is tied to your account or workspace. Usage through the API draws from the same allowance as the web app.
- You can have more than one. Separate keys for development, production and each project make it easy to revoke one without breaking the rest.
Where to find your ElevenLabs API key
The dashboard has moved this setting over time, which is why old tutorials and videos disagree. Early guides say to open the Profile tab and copy the key shown there. Current accounts manage keys in a dedicated API Keys section. The steps below cover the current layout.
- Sign in at elevenlabs.io with the account that should pay for the usage.
- Open your settings. Click your profile or workspace name, then look for workspace or account settings.
- Go to the API Keys tab. This lists every key you have created, with names and, on some plans, usage details.
- Create a key. Click the create button and give the key a name that says where it will live, such as
blog-narrator-prod. If the form offers permission or usage restrictions, set them now: a key that can only do text to speech is less dangerous if it leaks than one with full access. - Copy it immediately. For security, the full key may only be shown once. Paste it straight into your password manager or secrets store.
If you cannot see the API Keys tab, check that you are in the right workspace and that your role allows key management. Team workspaces sometimes restrict this to admins.
Lost the key? You cannot recover it. Delete the old entry and create a new ElevenLabs API key, then update every place that used the old one.

How to use an ElevenLabs API key in code
Once you have the key, store it in an environment variable rather than in your source code. On macOS or Linux:
export ELEVENLABS_API_KEY="paste-your-key-here"
In a project, put it in a .env file and make sure .env is listed in .gitignore before your first commit.
A direct text to speech call to ElevenLabs looks like this. The voice ID goes in the URL path, the text and model go in the JSON body, and the key goes in the xi-api-key header:
curl -X POST "https://api.elevenlabs.io/v1/text-to-speech/EkK5I93UQWFDigLMpZcX" \
-H "xi-api-key: $ELEVENLABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Hello from my first API call.", "model_id": "eleven_multilingual_v2"}' \
--output hello.mp3
The response body is the audio itself, so --output writes it straight to a file. If the file is a few hundred bytes of JSON instead of an MP3, open it: that is an error message, usually about the key or the quota.
Three habits save time here:
- Read the key from the environment in every language you use (
os.environin Python,process.envin Node.js). Never paste it into a script you might share. - Check the HTTP status code before saving the response, so an error does not get written to disk as a broken audio file.
- Pick the voice once and store its ID in config. Voice IDs are long strings, and a typo produces a not-found error that looks like a key problem.
Is there a free ElevenLabs API key?
Yes and no. ElevenLabs offers a free tier, and a free account can create an ElevenLabs API key that works with the API. That key draws from the free account’s monthly allowance, the same pool the web app uses. When the allowance is spent, requests fail until it resets or you upgrade. Free accounts also carry limits on some features and on commercial use, so read the current terms before you build a product on one.
What you will not find is a legitimate free unlimited key. The related searches tell the story: people look for “elevenlabs api key free github”, “free unlimited”, “reddit” and even “hack”. Here is what those results actually contain:
- Leaked keys. Someone committed their ElevenLabs API key to a public repository by mistake. Bots scan GitHub for exactly this pattern and drain such keys within minutes, and the owner revokes them as soon as they notice the bill.
- Shared keys. Posted on forums by people who want to share a paid quota. This breaks the terms of service and the key dies when the owner rotates it.
- Wrappers and proxies. Some projects promise free access through a shared backend. They are slow, often down, and you hand your text to an unknown third party.
Even if a borrowed key works today, an app built on it breaks the moment it is revoked, with no warning and no recourse. If cost is the concern, a small paid allowance or a pay-per-request option is cheaper than the time spent chasing working keys.
A common case from the search results: people using a free ElevenLabs API key inside a flashcard add-on such as HyperTTS for Anki. That is a reasonable use of the free tier, as long as the key is your own and your study volume fits the monthly allowance.
How to keep your ElevenLabs API key secure
A leaked key is a direct line to your credits and, on some setups, your cloned voices. These rules prevent nearly every leak.
Never ship the key to the browser or a mobile app
Anything inside front-end JavaScript or an app bundle can be extracted by any user in seconds. Instead, have the browser call your own backend, and let the backend call the voice API with the key it reads from its environment. Your backend can also enforce per-user limits, so one user cannot burn through the whole month.
Keep keys out of Git
- Add
.envto.gitignorebefore creating the file. - Turn on secret scanning in your Git host, which flags known key formats on push.
- If a key ever lands in a commit, treat it as leaked even if you delete the commit. Rotate it.
Use one key per project and environment
Separate keys for local development, staging and production mean you can revoke one without taking everything down, and the usage view tells you which project is spending what.
Restrict what each key can do
If the dashboard lets you limit a key’s permissions or set a spending cap, use it. A narration service only needs text to speech. It does not need access to voice cloning or account settings.
Rotate on a schedule and after staff changes
Create the new key, deploy it, confirm traffic works, then delete the old one. Doing it in that order avoids downtime.

Using ElevenLabs voices without an ElevenLabs API key
If your project already uses several AI models, a separate ElevenLabs API key is one more account, one more bill and one more secret to rotate. Unicorn API offers ElevenLabs models behind a single key that also covers image, video, music and chat models. You create the key at /keys, and every request is billed in credits from one balance.
Three ElevenLabs models are available:
| Model | Model ID | Price | Good for |
|---|---|---|---|
| Elevenlabs Text to Speech Multilingual V2 | elevenlabs-text-to-speech-multilingual-v2 | 12 credits per 1,000 characters | Narration and content in many languages where quality matters most |
| Elevenlabs Text to Speech Turbo V2.5 | elevenlabs-text-to-speech-turbo-2-5 | 6 credits per 1,000 characters | High-volume speech at half the credit cost |
| Elevenlabs Text to Dialogue V3 | elevenlabs-text-to-dialogue-v3 | 14 credits per request | Multi-speaker conversations, each line with its own voice |
Both text to speech models accept text, voice, speed, style, stability, similarity_boost, language_code, timestamps, and previous_text / next_text for keeping the delivery consistent across chunks of a long script. The dialogue model takes a dialogue array of lines, plus stability and language_code.
What it costs: a worked example
Text to speech is charged per started block of 1,000 characters, so the character count is rounded up. Say you narrate a 2,500-character blog post:
- Multilingual V2: 2,500 / 1,000 rounds up to 3 blocks, times 12 credits = 36 credits. On a monthly plan, where credits cost $0.01 each, that is $0.36. With top-up credits at $0.015 each, it is $0.54.
- Turbo V2.5: 3 blocks times 6 credits = 18 credits, which is $0.18 on a plan or $0.27 with top-ups.
- A dialogue request on Text to Dialogue V3 is a flat 14 credits: $0.14 on a plan, $0.21 with top-ups.
Monthly plans are Starter at $25, Creator at $50, Studio at $100 and Pro at $200, with credits at $0.01 each. Top-up credits cost $0.015 each and never expire, which suits occasional projects. Details are on the pricing page. You can also get the exact price of any request before running it by calling POST /v1/models/price; the API documentation covers the request format.
Code: generate speech in Python
Media models on Unicorn API run as jobs. You submit a job, poll it until its status is succeeded, then download the file from outputs[0].url. Authentication uses a standard Bearer header.
import os
import time
import requests
API = "https://api.unicornapi.net"
HEADERS = {
"Authorization": f"Bearer {os.environ['UNICORN_API_KEY']}",
"Content-Type": "application/json",
}
# 1. Submit the job
body = {
"model": "elevenlabs-text-to-speech-multilingual-v2",
"input": {
"text": "Welcome to the show. Today we look at how API keys work.",
"voice": "EkK5I93UQWFDigLMpZcX",
},
}
resp = requests.post(f"{API}/v1/jobs", json=body, headers=HEADERS)
resp.raise_for_status()
job = resp.json()
job_id = job["id"]
# 2. Poll until the job has succeeded
for _ in range(60):
job = requests.get(f"{API}/v1/jobs/{job_id}", headers=HEADERS).json()
if job["status"] == "succeeded":
break
time.sleep(2)
else:
raise TimeoutError(f"Job {job_id} did not finish, last status: {job['status']}")
# 3. Download the audio
audio_url = job["outputs"][0]["url"]
with open("welcome.mp3", "wb") as f:
f.write(requests.get(audio_url).content)
print("Saved welcome.mp3")
Code: a two-voice dialogue with curl
curl -X POST "https://api.unicornapi.net/v1/jobs" \
-H "Authorization: Bearer $UNICORN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "elevenlabs-text-to-dialogue-v3",
"input": {
"dialogue": [
{"text": "Did you rotate the production key?", "voice": "EkK5I93UQWFDigLMpZcX"},
{"text": "Yes, the old one is deleted.", "voice": "EkK5I93UQWFDigLMpZcX"}
]
}
}'
# Then poll with the returned id:
curl "https://api.unicornapi.net/v1/jobs/JOB_ID" \
-H "Authorization: Bearer $UNICORN_API_KEY"
Swap the second voice ID for any other voice you want in the conversation. To hear the voices before writing code, try them in the audio playground. If you work in Cursor or Claude Code, the same key works through MCP, as described on the agents page.
The same balance also pays for audio beyond speech: short sound clips with Ai Music API Sounds at 2.5 credits per track, or full songs as covered in the Suno API guide. The model catalog lists everything else.
Common ElevenLabs API key errors and how to fix them
Most problems with an ElevenLabs API key come down to a handful of causes. Work through this list in order.
| Symptom | Likely cause | Fix |
|---|---|---|
| 401 Unauthorized | Key sent as Authorization: Bearer instead of xi-api-key | Use the xi-api-key header for ElevenLabs. (Unicorn API is the opposite: it uses Bearer.) |
| 401 right after copying a new key | A trailing space or newline came with the copy | Re-copy the key, or strip whitespace when reading the variable |
| 401 only in production | The environment variable is not set on the server | Log the length of the variable (never the value) at startup to confirm it loaded |
| Worked yesterday, fails today | Key deleted, rotated or restricted by a teammate | Check the API Keys tab and create a new key if needed |
| Quota or limit error | The monthly allowance is used up | Wait for the reset, upgrade, or move volume to a cheaper model |
| 404 or voice not found | Typo in the voice ID, or a voice your account cannot access | Copy the ID again from your voice library |
| Saved MP3 will not play | The response was an error JSON saved as audio | Check the status code before writing the file |
One more trap: code that falls back to a hardcoded key when the environment variable is missing. It hides configuration mistakes and almost always ends up in a commit. Fail loudly instead, with an error message that names the missing variable.
Which option should you choose?
Both routes reach the same ElevenLabs voices, so the choice depends on the rest of your stack.
- Get your own ElevenLabs API key if voice is the only AI feature in your product, you want features that live only in the ElevenLabs dashboard, or you already pay for an ElevenLabs plan.
- Use a Unicorn API key if your app also generates images, video, music or chat responses, and you would rather manage one key, one bill and one credit balance. Per-request prices, such as 6 credits per 1,000 characters on Turbo V2.5, make costs easy to forecast, and the price endpoint tells you the exact cost before you run anything.
Whichever you pick, the same rules hold: keep the key on the server, give each project its own key, rotate after any possible exposure, and ignore the free unlimited keys floating around GitHub and Reddit. A key you control is the only one your app can rely on.
Frequently asked questions
Where is my API key on ElevenLabs?
Sign in to the ElevenLabs website and open your profile or workspace settings, then go to the API Keys tab. Older guides point to the Profile tab, which is where the key used to sit. Create a new key, give it a name and copy it right away. For security, the dashboard may not show the full key again, so if you lose it, delete it and make a new one.
Where can I find the Cloud Text to Speech API key?
If you mean Google Cloud Text-to-Speech, open the Google Cloud Console, enable the Text-to-Speech API for your project, then go to APIs and Services, Credentials, and create an API key or a service account. That key only works with Google's service. An ElevenLabs API key is separate and comes from the ElevenLabs dashboard, and a Unicorn API key comes from your Unicorn API account.
Is there a free ElevenLabs API key?
ElevenLabs has a free tier, and a free account can create an API key that draws from the same monthly allowance as the web app. When the allowance runs out, requests fail until it resets or you upgrade. The free tier also comes with restrictions on some features and on commercial use, so check the current terms before you ship anything with it.
Are the free unlimited ElevenLabs API keys on GitHub or Reddit safe to use?
No. A key posted publicly either belongs to someone who leaked it by accident or was shared against the terms of service. Using it means spending another person's quota, it can be revoked at any moment, and your app breaks when that happens. Leaked keys are also scanned and abused within minutes, so any project built on one is unreliable from day one.
Can I use ElevenLabs voices without an ElevenLabs API key?
Yes. Unicorn API offers ElevenLabs Multilingual V2, Turbo V2.5 and Text to Dialogue V3 behind one Unicorn API key. You send a job to POST /v1/jobs, poll it until the status is succeeded, then download the audio URL. Billing is in credits, for example 6 credits per 1,000 characters on Turbo V2.5, and the same key also covers image, video, music and chat models.
Why does my ElevenLabs API key return a 401 error?
A 401 almost always means the server did not receive a valid key. Common causes are sending the key in an Authorization Bearer header instead of xi-api-key, a stray space or newline copied with the key, an environment variable that was never loaded, or a key that has been deleted or restricted. Print the length of the variable your code reads, not the key itself, to confirm it is set.