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: 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

Models

Exposed as a StrEnum for autocomplete:

Output formats

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

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