{"record":{"id":"6bb645ebf3fe06bc","repo":"BerriAI/litellm","slug":"azure-ai-speech-transcription-requires-a-cognitive","errorCode":null,"errorMessage":"Azure AI Speech transcription requires a Cognitive Services or STT Speech endpoint, not an Azure OpenAI endpoint.","messagePattern":"Azure AI Speech transcription requires a Cognitive Services or STT Speech endpoint, not an Azure OpenAI endpoint\\.","errorType":"validation","errorClass":"AzureSpeechAudioTranscriptionException","httpStatus":400,"severity":"error","filePath":"litellm/llms/azure/audio_transcription/transformation.py","lineNumber":163,"sourceCode":"            message=error_message,\n            status_code=status_code,\n            headers=headers,\n        )\n\n    def _resolve_stt_base_url(self, api_base: str) -> str:\n        api_base = api_base.rstrip(\"/\")\n        parsed_url: Final = urlparse(api_base)\n        hostname: Final = parsed_url.hostname or \"\"\n\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_stt_base_url(region=region)\n\n        if self._is_stt_endpoint(hostname=hostname):\n            return f\"{parsed_url.scheme}://{hostname}\"\n\n        if self._is_azure_openai_endpoint(hostname=hostname):\n            raise AzureSpeechAudioTranscriptionException(\n                message=(\n                    \"Azure AI Speech transcription requires a Cognitive Services \"\n                    \"or STT Speech endpoint, not an Azure OpenAI endpoint.\"\n                ),\n                status_code=400,\n            )\n\n        return api_base\n\n    def _is_cognitive_services_endpoint(self, hostname: str) -> bool:\n        return hostname == self.COGNITIVE_SERVICES_DOMAIN or hostname.endswith(f\".{self.COGNITIVE_SERVICES_DOMAIN}\")\n\n    def _is_stt_endpoint(self, hostname: str) -> bool:\n        return hostname == self.STT_SPEECH_DOMAIN or hostname.endswith(f\".{self.STT_SPEECH_DOMAIN}\")\n\n    def _is_azure_openai_endpoint(self, hostname: str) -> bool:\n        return hostname.endswith(\".openai.azure.com\")\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure/audio_transcription/transformation.py#L145-L181","documentation":"LiteLLM resolves the Azure Speech base URL from the hostname of your `api_base`. If the hostname is recognized as an Azure OpenAI endpoint (e.g. <resource>.openai.azure.com) it raises this 400, because Azure AI Speech transcription calls the Speech/Cognitive Services API, not the Azure OpenAI audio API. This guard prevents a guaranteed-to-fail request (wrong API surface, wrong auth header).","triggerScenarios":"Passing api_base='https://myresource.openai.azure.com' (copied from an existing Azure OpenAI deployment) to a transcription call routed through the Azure Speech handler.","commonSituations":"Teams with existing Azure OpenAI deployments reuse that endpoint for transcription out of habit; config templates for Azure OpenAI chat are duplicated for speech without changing the endpoint; confusion because Azure OpenAI also offers whisper audio APIs.","solutions":["Switch api_base to your Speech resource endpoint: https://{region}.api.cognitive.microsoft.com or https://{region}.stt.speech.microsoft.com.","If you actually want Azure OpenAI Whisper, use an azure/ deployment model name routed to Azure OpenAI instead of the Azure Speech integration.","Create a Speech resource in the Azure portal if none exists and copy its endpoint."],"exampleFix":"# before\nlitellm.transcription(model='azure/speech', file=f, api_base='https://myres.openai.azure.com', api_key=key)\n\n# after\nlitellm.transcription(model='azure/speech', file=f, api_base='https://eastus.api.cognitive.microsoft.com', api_key=key)","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\nhost = urlparse(api_base).hostname or ''\nif host.endswith('openai.azure.com'):\n    raise ValueError(f'{api_base} is an Azure OpenAI endpoint; use a Cognitive Services/STT endpoint for Speech transcription.')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep separate config keys for Azure OpenAI endpoints and Speech endpoints.","Add a config lint rule rejecting '*.openai.azure.com' values for speech models."],"tags":["azure","speech","endpoint","misconfiguration","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}