Integrate the ElevenLabs Text-to-Speech API to generate and stream audio

domain: elevenlabs.io · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Authenticate by including your API key in the 'xi-api-key' HTTP header on all requests — obtain your key from the ElevenLabs dashboard under Profile > API Key
  2. List available voices by GETting 'https://api.elevenlabs.io/v1/voices' — the response contains an array of voice objects with 'voice_id', 'name', 'labels', and 'preview_url'; use the 'voice_id' value to specify a voice in generation requests
  3. Generate speech by POSTing to 'https://api.elevenlabs.io/v1/text-to-speech/{voice_id}' with a JSON body containing 'text' (the content to synthesize), 'model_id' (e.g., 'eleven_flash_v2_5' for low-latency or 'eleven_multilingual_v2' for quality), and optionally 'voice_settings' with 'stability' and 'similarity_boost' floats between 0 and 1
  4. Set the 'Accept' header to 'audio/mpeg' to receive MP3 output — the response body is the raw audio binary; write it directly to a file or pipe it to a player
  5. For streaming audio in real time, POST to 'https://api.elevenlabs.io/v1/text-to-speech/{voice_id}/stream' — the response is a chunked stream of audio bytes you can forward directly to an audio player or WebSocket client without waiting for the full file
  6. For the lowest latency in voice agent applications, use the WebSocket endpoint at 'wss://api.elevenlabs.io/v1/text-to-speech/{voice_id}/stream-input' which accepts text chunks incrementally and returns audio chunks as soon as each is synthesized

Known gotchas

Related routes

Transcribe real-time audio with AssemblyAI Universal-Streaming via the v3 WebSocket endpoint
assemblyai.com · 5 steps · unrated
Dub a video or audio file into another language using the ElevenLabs Dubbing API
elevenlabs.io · 5 steps · unrated
Enhance and transcode audio in a single request using Dolby.io Media APIs
dolby.io · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans