Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Elevenlabs Elevenlabs python Model And Format Selection

From Leeroopedia
Knowledge Sources
Domains Speech_Synthesis, Configuration
Last Updated 2026-02-15 00:00 GMT

Overview

Configuration pattern for selecting TTS model and audio output format via string parameters in the elevenlabs-python SDK.

Description

Model and output format are string parameters passed to TTS methods (convert, stream, convert_realtime). The SDK defines an OutputFormat type alias for valid format strings. Model IDs are plain strings obtained from the ElevenLabs API or documentation.

This is a Pattern Doc — there is no standalone function to call. These parameters are part of the TTS method signatures.

Usage

Pass model_id and output_format to any TTS method. Use the OutputFormat type for IDE autocomplete of valid format strings.

Code Reference

Source Location

  • Repository: elevenlabs-python
  • File: src/elevenlabs/types/output_format.py
  • Lines: L1-20

Interface Specification

# OutputFormat is a Literal type alias:
OutputFormat = typing.Literal[
    "mp3_22050_32",    # MP3, 22.05kHz, 32kbps
    "mp3_44100_32",    # MP3, 44.1kHz, 32kbps
    "mp3_44100_64",    # MP3, 44.1kHz, 64kbps
    "mp3_44100_96",    # MP3, 44.1kHz, 96kbps
    "mp3_44100_128",   # MP3, 44.1kHz, 128kbps (default)
    "mp3_44100_192",   # MP3, 44.1kHz, 192kbps (Creator+ tier)
    "pcm_16000",       # Raw PCM, 16kHz
    "pcm_22050",       # Raw PCM, 22.05kHz
    "pcm_24000",       # Raw PCM, 24kHz
    "pcm_44100",       # Raw PCM, 44.1kHz (Pro+ tier)
    "ulaw_8000",       # mu-law, 8kHz (telephony/Twilio)
]

# Model IDs (common values):
model_id = "eleven_multilingual_v2"    # Multilingual, high quality
model_id = "eleven_turbo_v2_5"        # English-optimized, low latency
model_id = "eleven_flash_v2_5"        # Fastest generation
model_id = "eleven_monolingual_v1"    # Legacy English-only

Import

from elevenlabs.types import OutputFormat

I/O Contract

Inputs

Name Type Required Description
model_id str No Model identifier string passed to TTS methods
output_format OutputFormat (str) No Audio encoding format string passed to TTS methods

Outputs

Name Type Description
(configuration) str values Passed to TTS methods to control synthesis model and audio encoding

Usage Examples

Selecting Model and Format

from elevenlabs import ElevenLabs

client = ElevenLabs()

# High quality multilingual
audio = client.text_to_speech.convert(
    voice_id="JBFqnCBsd6RMkjVDRZzb",
    text="Bonjour le monde!",
    model_id="eleven_multilingual_v2",
    output_format="mp3_44100_128",
)

# Low latency for real-time apps
audio = client.text_to_speech.convert(
    voice_id="JBFqnCBsd6RMkjVDRZzb",
    text="Quick response needed.",
    model_id="eleven_turbo_v2_5",
    output_format="pcm_16000",
)

# Telephony format for Twilio
audio = client.text_to_speech.convert(
    voice_id="JBFqnCBsd6RMkjVDRZzb",
    text="Please hold while I transfer your call.",
    model_id="eleven_turbo_v2_5",
    output_format="ulaw_8000",
)

Related Pages

Implements Principle

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment