How to hit the ElevenLabs API

ElevenLabs' API lives at https://api.elevenlabs.io. Text-to-speech takes a voice id in the URL and returns audio bytes; everything else returns JSON.

Authentication

Create a key under Settings → API keys and send it as the xi-api-key header (not Authorization). In the examples it's written {{ELEVENLABS_API_KEY}}.

Full reference: https://elevenlabs.io/docs/api-reference/introduction

Text to speech

Returns an MP3. From the command line add --output speech.mp3. The voice id is the one ElevenLabs uses in its own examples.

curl "https://api.elevenlabs.io/v1/text-to-speech/JBFqnCBsd6RMkjVDRZzb?output_format=mp3_44100_128" \
  -H "xi-api-key: {{ELEVENLABS_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{"text": "The first move is what sets everything in motion.", "model_id": "eleven_multilingual_v2"}'
Run in PostTaco

List voices

Your voices and ones you've added from the library, with ids to use in text-to-speech.

curl "https://api.elevenlabs.io/v2/voices?page_size=10" \
  -H "xi-api-key: {{ELEVENLABS_API_KEY}}"
Run in PostTaco

List models

Model ids for model_id, with the languages each supports.

curl https://api.elevenlabs.io/v1/models \
  -H "xi-api-key: {{ELEVENLABS_API_KEY}}"
Run in PostTaco

Check your quota

Characters used and remaining this billing period.

curl https://api.elevenlabs.io/v1/user/subscription \
  -H "xi-api-key: {{ELEVENLABS_API_KEY}}"
Run in PostTaco