{"record":{"id":"a94ad84786d99b96","repo":"BerriAI/litellm","slug":"elevenlabs-voice-id-is-required-pass-voice-when","errorCode":null,"errorMessage":"ElevenLabs voice_id is required. Pass `voice` when calling `litellm.speech()`.","messagePattern":"ElevenLabs voice_id is required\\. Pass `voice` when calling `litellm\\.speech\\(\\)`\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"litellm/llms/elevenlabs/text_to_speech/transformation.py","lineNumber":108,"sourceCode":"\n        if isinstance(voice, str) and voice.strip():\n            mapped_voice = self._extract_voice_id(voice)\n        elif isinstance(voice, dict):\n            for key in (\"voice_id\", \"id\", \"name\"):\n                candidate = voice.get(key)\n                if isinstance(candidate, str) and candidate.strip():\n                    mapped_voice = self._extract_voice_id(candidate)\n                    break\n        elif voice is not None:\n            mapped_voice = self._extract_voice_id(str(voice))\n\n        if mapped_voice is None:\n            voice_override: Final = params.pop(\"voice_id\", None)\n            if isinstance(voice_override, str) and voice_override.strip():\n                mapped_voice = self._extract_voice_id(voice_override)\n\n        if mapped_voice is None:\n            raise ValueError(\"ElevenLabs voice_id is required. Pass `voice` when calling `litellm.speech()`.\")\n\n        return mapped_voice\n\n    def map_openai_params(\n        self,\n        model: str,\n        optional_params: dict,\n        voice: str | dict | None = None,\n        drop_params: bool = False,\n        kwargs: dict[str, Any] | None = None,\n    ) -> tuple[str | None, dict]:\n        \"\"\"\n        Map OpenAI parameters to ElevenLabs TTS parameters\n        \"\"\"\n        mapped_params: Final[dict[str, Any]] = {}\n        query_params: Final[dict[str, Any]] = {}\n\n        # Work on a copy so we don't mutate the caller's dictionary","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/elevenlabs/text_to_speech/transformation.py#L90-L126","documentation":"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.","triggerScenarios":"Thrown at litellm/llms/elevenlabs/text_to_speech/transformation.py:108 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass voice=<voice_id> when calling litellm.speech() for ElevenLabs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}