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
import { ElevenLabsClient, play } from "elevenlabs";

const client = new ElevenLabsClient();
const audio = await client.textToSpeech.convert("JBFqnCBsd6RMkjVDRZzb", {
  text: "The first move is what sets everything in motion.",
  model_id: "eleven_multilingual_v2",
  output_format: "mp3_44100_128",
});

await 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.