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
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:With the ElevenLabs SDK installed, create a file called Execute the code with
Install the ElevenLabs SDK with npm
example.mjs
and copy one of the following examples into it:Convert text into life-like audio
node example.mjs
(or the equivalent command for Deno or Bun). In a few seconds, you should hear the audio play through your speaker.