BerriAI/litellm · error

ElevenLabs voice_id is required. Pass `voice` when calling…

Error message

ElevenLabs voice_id is required. Pass `voice` when calling `litellm.speech()`.

What it means

Parameter guard in the ElevenLabs TTS transformation: after trying string/dict voice inputs and the voice_id override, no non-empty voice identifier was resolved. ElevenLabs requires a specific voice_id to synthesize speech, so the call is rejected.

Solutions

  1. Pass voice=<voice_id> when calling litellm.speech() for ElevenLabs.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/elevenlabs/text_to_speech/transformation.py:108 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/a94ad84786d99b96. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/elevenlabs/text_to_speech/transformation.py:108

        if isinstance(voice, str) and voice.strip():
            mapped_voice = self._extract_voice_id(voice)
        elif isinstance(voice, dict):
            for key in ("voice_id", "id", "name"):
                candidate = voice.get(key)
                if isinstance(candidate, str) and candidate.strip():
                    mapped_voice = self._extract_voice_id(candidate)
                    break
        elif voice is not None:
            mapped_voice = self._extract_voice_id(str(voice))

        if mapped_voice is None:
            voice_override: Final = params.pop("voice_id", None)
            if isinstance(voice_override, str) and voice_override.strip():
                mapped_voice = self._extract_voice_id(voice_override)

        if mapped_voice is None:
            raise ValueError("ElevenLabs voice_id is required. Pass `voice` when calling `litellm.speech()`.")

        return mapped_voice

    def map_openai_params(
        self,
        model: str,
        optional_params: dict,
        voice: str | dict | None = None,
        drop_params: bool = False,
        kwargs: dict[str, Any] | None = None,
    ) -> tuple[str | None, dict]:
        """
        Map OpenAI parameters to ElevenLabs TTS parameters
        """
        mapped_params: Final[dict[str, Any]] = {}
        query_params: Final[dict[str, Any]] = {}

        # Work on a copy so we don't mutate the caller's dictionary

View on GitHub (pinned to 77b7c6c40c)