{"record":{"id":"711dd91846edf6b9","repo":"BerriAI/litellm","slug":"api-base-is-required-for-azure-ava-tts-format-ht","errorCode":null,"errorMessage":"api_base is required for Azure AVA TTS. Format: https://{region}.api.cognitive.microsoft.com or https://{region}.tts.speech.microsoft.com","messagePattern":"api_base is required for Azure AVA TTS\\. Format: https://(.+?)\\.api\\.cognitive\\.microsoft\\.com or https://(.+?)\\.tts\\.speech\\.microsoft\\.com","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure/text_to_speech/transformation.py","lineNumber":325,"sourceCode":"        # User-Agent\n        validated_headers[\"User-Agent\"] = \"litellm\"\n\n        return validated_headers\n\n    def get_complete_url(\n        self,\n        model: str,\n        api_base: str | None,\n        litellm_params: dict,\n    ) -> str:\n        \"\"\"\n        Get the complete URL for Azure AVA TTS request\n\n        Azure TTS endpoint format:\n        https://{region}.tts.speech.microsoft.com/cognitiveservices/v1\n        \"\"\"\n        if api_base is None:\n            raise ValueError(\n                f\"api_base is required for Azure AVA TTS. \"\n                f\"Format: https://{{region}}.{self.COGNITIVE_SERVICES_DOMAIN} or \"\n                f\"https://{{region}}.{self.TTS_SPEECH_DOMAIN}\"\n            )\n\n        # Remove trailing slash and parse URL\n        api_base = api_base.rstrip(\"/\")\n        parsed_url: Final = urlparse(api_base)\n        hostname: Final = parsed_url.hostname or \"\"\n\n        # Check if it's a Cognitive Services endpoint (convert to TTS endpoint)\n        if self._is_cognitive_services_endpoint(hostname=hostname):\n            region: Final = self._extract_region_from_hostname(hostname=hostname, domain=self.COGNITIVE_SERVICES_DOMAIN)\n            return self._build_tts_url(region=region)\n\n        # Check if it's already a TTS endpoint\n        if self._is_tts_endpoint(hostname=hostname):\n            if not api_base.endswith(self.TTS_ENDPOINT_PATH):","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure/text_to_speech/transformation.py#L307-L343","documentation":"LiteLLM's Azure AVA (Azure Speech) text-to-speech provider builds the TTS endpoint URL from the api_base you pass. If api_base is None it cannot construct https://{region}.tts.speech.microsoft.com/cognitiveservices/v1 and raises a ValueError telling you the two accepted endpoint formats. This is a configuration error thrown before any network request is made.","triggerScenarios":"Calling litellm.tts() or the speech endpoint with model='azure/<tts-model>' (or an AVA voice) without api_base in the request and without AZURE_API_BASE/AZURE_AI_API_BASE set in the environment; or passing api_key only and relying on a deployment name, which works for Azure OpenAI but not for the Azure Speech TTS route.","commonSituations":"Reusing Azure OpenAI chat config (api_key + api_version, no api_base) for TTS; forgetting that the Speech service needs a region-specific endpoint from the Azure Portal ('Resource management > Keys and Endpoint'); typo'ing the env var name; setting api_base in provider_config instead of the top-level call.","solutions":["Pass api_base explicitly, e.g. litellm.tts(model='azure/<voice>', api_base='https://eastus.tts.speech.microsoft.com', api_key=..., input=...).","Or use the Cognitive Services form https://eastus.api.cognitive.microsoft.com — LiteLLM detects it and rewrites it to the TTS host.","If set via env, confirm AZURE_API_BASE (or the documented AZURE_AI_API_BASE for this route) is exported in the process running litellm, not just your shell.","Copy the exact endpoint value from the Azure Speech resource's Keys and Endpoint page; the {region} placeholder must be replaced with a real region like westeurope."],"exampleFix":"# before\nresp = litellm.tts(model='azure/ava-Ash', api_key=AZURE_KEY, input='hello')\n\n# after\nresp = litellm.tts(\n    model='azure/ava-Ash',\n    api_key=AZURE_KEY,\n    api_base='https://eastus.tts.speech.microsoft.com',\n    input='hello',\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef azure_tts_config_ok(api_base: str | None) -> bool:\n    base = api_base or os.getenv('AZURE_API_BASE')\n    return base is not None and base.startswith('https://')","typeGuard":null,"tryCatchPattern":"try:\n    litellm.tts(model=..., api_base=base, api_key=key, input=text)\nexcept ValueError as e:\n    if 'api_base is required for Azure AVA TTS' in str(e):\n        raise ConfigurationError('Set AZURE_API_BASE to https://<region>.tts.speech.microsoft.com') from e\n    raise","preventionTips":["Keep Azure provider config (api_base + api_key) in one typed settings object validated at app startup.","Add a startup assertion for AZURE_API_BASE whenever TTS routes are enabled.","Document the exact endpoint format next to the config so {region} placeholders never reach production."],"tags":["azure","tts","configuration","api-base","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}