Quickstart

Start generating your first text-to-speech using Python and ElevenLabs API

The ElevenLabs API provides a simple interface to state-of-the-art audio models and features. Follow this guide to learn how to create lifelike speech, generate and modify voices, produce immersive sound effects, isolate background noise from audio, and seamlessly dub audio/videos.

Create and export an API key

Create an API key in the dashboard here, which you’ll use to securely access the API. Store the key in a safe location, like a .zshrc file or another text file on your computer. Once you’ve generated an API key, export it as an environment variable in your terminal.

Export an environment variable on macOS or Linux systems
$export ELEVENLABS_API_KEY="your_api_key_here"

Make your first API request

With your ElevenLabs API key exported as an environment variable, you’re ready to make your first API request. You can either use the REST API directly with the HTTP client of your choice, or use one of our official SDKs as shown below.

To use the ElevenLabs API in server-side JavaScript environments like Node.js, Deno, or Bun, you can use the official ElevenLabs SDK for TypeScript and JavaScript. Get started by installing the SDK using npm or your preferred package manager:

Install the ElevenLabs SDK with npm
$npm install elevenlabs

To play the audio through your speakers, you may be prompted to install MPV and/or ffmpeg.

With the ElevenLabs SDK installed, create a file called example.mjs and copy one of the following examples into it:

Convert text into life-like audio
1import { ElevenLabsClient, play } from "elevenlabs";
2
3const client = new ElevenLabsClient();
4const audio = await client.textToSpeech.convert("JBFqnCBsd6RMkjVDRZzb", {
5 text: "The first move is what sets everything in motion.",
6 model_id: "eleven_multilingual_v2",
7 output_format: "mp3_44100_128",
8});
9
10await play(audio);

Execute the code with node example.mjs (or the equivalent command for Deno or Bun). In a few seconds, you should hear the audio play through your speaker.