Skip to main content

ElevenLabs TTS (REST)

ElevenLabsTTS is the default ElevenLabs TTS adapter. It streams audio chunks over the HTTP /v1/text-to-speech/{voice_id}/stream endpoint and exposes the same synthesize(text) async iterator as the rest of Patter’s TTS providers.

REST vs WebSocket — when to use which

ElevenLabs ships two streaming transports. Patter wraps both:
TransportClassUse when
HTTP / RESTElevenLabsTTS (this page)Default. Simpler, more forgiving on flaky networks, supports every model including eleven_v3*.
WebSocketElevenLabsWebSocketTTSYou’re latency-bound on TTS time-to-first-byte and willing to give up eleven_v3 support. Saves ~50 ms per utterance vs REST.
Pick REST unless you’ve measured a per-utterance latency problem and confirmed you don’t need eleven_v3. The REST adapter is the canonical choice and gets every new ElevenLabs model on day one.

Install

ElevenLabsTTS ships in the core getpatter package — no extras needed:

Quickstart

Carrier-tuned factories

For real phone calls always reach for the carrier-specific factories — they pre-set the right output_format so the SDK can skip resampling and PCM ↔ μ-law transcoding on the audio path:
for_twilio / forTwilio saves ~30–80 ms first-byte plus per-frame CPU and removes a potential aliasing source. If your Telnyx profile is pinned to PCMU/8000 instead, construct directly with output_format='ulaw_8000'.

Carrier auto-detect — set_telephony_carrier

When you don’t know the carrier at construction time, StreamHandler calls set_telephony_carrier(carrier) at call start to advise the provider of the wire format:
When output_format was passed explicitly to the constructor (or via for_twilio / for_telnyx), set_telephony_carrier is a no-op — the user’s choice always wins. Calling with an unknown carrier ("" / "custom") is also a no-op.

Constructor

ParameterDefaultDescription
api_key / apiKeyenvElevenLabs API key.
voice_id / voiceId"21m00Tcm4TlvDq8ikWAM" (Rachel)Voice ID or curated display name ("rachel", "alloy", …).
model_id / modelId"eleven_flash_v2_5"See Models.
output_format / outputFormat"pcm_16000"See Output formats.
voice_settings / voiceSettings{ stability, similarity_boost, style, use_speaker_boost }.
language_code / languageCodeBCP-47 / ISO 639-1 language hint.
chunk_size / chunkSize4096Stream chunk size in bytes.

Models

Model IDNotes
eleven_flash_v2_5 (default)Fastest TTFT (~75 ms). Best for live phone calls.
eleven_turbo_v2_5Balanced quality / speed.
eleven_multilingual_v2Best multilingual support.
eleven_monolingual_v1Legacy English-only.
eleven_v3Newest, highest quality. Slower TTFT. Not supported by the WebSocket variant.
Exposed as a StrEnum for autocomplete:

Output formats

FormatUse case
pcm_16000 (default)Web playback, dashboard previews, Telnyx L16/16000 carrier path.
ulaw_8000Twilio Media Streams (μ-law @ 8 kHz native).
pcm_8000 / pcm_22050 / pcm_24000 / pcm_44100Other PCM rates.
mp3_22050_32mp3_44100_192MP3 at various bitrates.

Voice ID resolution

Pass either an opaque 20-char ElevenLabs voice ID ("21m00Tcm4TlvDq8ikWAM") or a curated display name. The SDK ships a built-in name → ID map for common voices ("rachel", "bella", "matilda", etc.) plus an "alloy" alias for cross-provider portability with OpenAI naming. Unknown strings are passed through unchanged so custom voices keep working.

Pricing

Model$/1k chars
eleven_flash_v2_5 (default)0.06
eleven_turbo_v2_50.05
eleven_multilingual_v20.18
eleven_monolingual_v10.18
eleven_v30.30
Pricing is auto-resolved from DEFAULT_PRICING per model — no override needed unless you’re on a custom ElevenLabs plan. See Metrics for how to register custom rates.

See also