{"record":{"id":"9460ba7c8dce79a8","repo":"BerriAI/litellm","slug":"error-message-9460ba","errorCode":null,"errorMessage":"{error_message}","messagePattern":"\\{error_message\\}","errorType":"http","errorClass":"BaseLLMException","httpStatus":null,"severity":"error","filePath":"litellm/llms/base_llm/text_to_speech/transformation.py","lineNumber":139,"sourceCode":"                - body: The request body (JSON dict, XML string, or binary data)\n                - headers: Provider-specific headers to merge with base headers\n        \"\"\"\n\n    @abstractmethod\n    def transform_text_to_speech_response(\n        self,\n        model: str,\n        raw_response: httpx.Response,\n        logging_obj: LiteLLMLoggingObj,\n    ) -> \"HttpxBinaryResponseContent\":\n        \"\"\"\n        Transform provider response to standard format\n        \"\"\"\n\n    def get_error_class(self, error_message: str, status_code: int, headers: dict) -> BaseLLMException:\n        from ..chat.transformation import BaseLLMException\n\n        raise BaseLLMException(\n            status_code=status_code,\n            message=error_message,\n            headers=headers,\n        )\n","sourceCodeStart":121,"sourceCodeEnd":144,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/base_llm/text_to_speech/transformation.py#L121-L144","documentation":"The generic error constructor of BaseTextToSpeechConfig: when a TTS request fails at the HTTP layer (non-2xx), litellm calls get_error_class(), which raises BaseLLMException carrying the provider's message ('{error_message}' in the traceback is that verbatim text), the status code, and headers. Callers usually see it mapped to a litellm.*StatusError or the raw BaseLLMException.","triggerScenarios":"litellm.text_to_speech() hitting provider errors: 401 bad key, 400 unsupported voice/format combination, 429 quota, 5xx provider outage — the transformation layer converts the failed response into BaseLLMException.","commonSituations":"Wrong voice name for the model; requesting an unsupported response_format (e.g. mp3 vs wav/opus on some backends); expired keys; self-hosted TTS server returning 404 because the route doesn't match the OpenAI schema.","solutions":["Inspect status_code and the provider message on the exception; the root cause is almost always the upstream request (auth, voice, format, endpoint path).","Validate voice/format against the provider's supported list before calling.","For self-hosted backends, confirm the api_base path matches the OpenAI /audio/speech schema.","Handle 429 with retries/backoff via litellm's num_retries or router fallbacks."],"exampleFix":"# before\nresp = litellm.text_to_speech(model=\"openai/tts-1\", voice=\"sarah\", input=\"hi\")  # unknown voice\n\n# after\nresp = litellm.text_to_speech(model=\"openai/tts-1\", voice=\"alloy\", input=\"hi\")  # supported voice\n\ntry:\n    resp = litellm.text_to_speech(model=\"openai/tts-1\", voice=\"alloy\", input=\"hi\")\nexcept Exception as e:\n    status = getattr(e, \"status_code\", None)\n    if status == 400:\n        logger.warning(\"bad TTS request: %s\", e)","handlingStrategy":"try-catch","validationCode":"SUPPORTED_VOICES = {\"alloy\", \"echo\", \"fable\", \"onyx\", \"nova\", \"shimmer\"}\nassert voice in SUPPORTED_VOICES, f\"unsupported voice {voice}\"","typeGuard":"def is_tts_provider_error(e: BaseException) -> bool:\n    return getattr(e, \"__class__\", None).__name__ == \"BaseLLMException\" and hasattr(e, \"status_code\")","tryCatchPattern":"try:\n    speech = litellm.text_to_speech(model=\"openai/tts-1\", voice=voice, input=text)\nexcept BaseLLMException as e:\n    if e.status_code == 400:\n        voice = \"alloy\"  # fall back to a universally supported voice\n        speech = litellm.text_to_speech(model=\"openai/tts-1\", voice=voice, input=text)\n    else:\n        raise","preventionTips":["Pin voice/format pairs validated against the provider's docs before calling.","For self-hosted TTS, verify the endpoint implements the OpenAI /audio/speech schema."],"tags":["text-to-speech","http-error","provider-error","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}