{"record":{"id":"6c946c805d8961af","repo":"BerriAI/litellm","slug":"api-base-is-required-for-azure-ai-speech-transcrip","errorCode":null,"errorMessage":"api_base is required for Azure AI Speech transcription. Use a Cognitive Services endpoint like https://{region}.api.cognitive.microsoft.com or an STT endpoint like https://{region}.stt.speech.microsoft.com.","messagePattern":"api_base is required for Azure AI Speech transcription\\. Use a Cognitive Services endpoint like https://(.+?)\\.api\\.cognitive\\.microsoft\\.com or an STT endpoint like https://(.+?)\\.stt\\.speech\\.microsoft\\.com\\.","errorType":"validation","errorClass":"AzureSpeechAudioTranscriptionException","httpStatus":400,"severity":"error","filePath":"litellm/llms/azure/audio_transcription/transformation.py","lineNumber":94,"sourceCode":"\n        validated_headers: Final = headers.copy()\n        validated_headers[\"Ocp-Apim-Subscription-Key\"] = api_key\n        validated_headers[\"Content-Type\"] = validated_headers.get(\"Content-Type\", \"audio/wav\")\n        validated_headers[\"Accept\"] = \"application/json\"\n        return validated_headers\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        api_key: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict,\n        stream: bool | None = None,\n    ) -> str:\n        api_base = api_base or get_secret_str(\"AZURE_SPEECH_API_BASE\")\n        if api_base is None:\n            raise AzureSpeechAudioTranscriptionException(\n                message=(\n                    \"api_base is required for Azure AI Speech transcription. \"\n                    \"Use a Cognitive Services endpoint like \"\n                    \"https://{region}.api.cognitive.microsoft.com or an STT \"\n                    \"endpoint like https://{region}.stt.speech.microsoft.com.\"\n                ),\n                status_code=400,\n            )\n\n        base_url: Final = self._resolve_stt_base_url(api_base=api_base)\n        query_params: Final = {\n            \"language\": optional_params.get(\"language\", self.DEFAULT_LANGUAGE),\n            \"format\": self._get_azure_response_format(optional_params.get(\"response_format\")),\n        }\n        return f\"{base_url}{self.STT_ENDPOINT_PATH}?{urlencode(query_params)}\"\n\n    def transform_audio_transcription_request(\n        self,","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure/audio_transcription/transformation.py#L76-L112","documentation":"Azure AI Speech transcription in LiteLLM needs a Cognitive Services or STT Speech endpoint to build the full request URL. It is taken from the `api_base` argument or the AZURE_SPEECH_API_BASE environment variable. When absent, this 400 error is raised with guidance on the two accepted endpoint shapes.","triggerScenarios":"Calling transcription with an Azure Speech model but no `api_base` argument and no AZURE_SPEECH_API_BASE env var; or setting AZURE_API_BASE (Azure OpenAI variable) instead of AZURE_SPEECH_API_BASE.","commonSituations":"Teams already using Azure OpenAI assume the same env vars cover Speech; the endpoint was configured only in a different service's config; hostname typos in region name cause devs to remove api_base entirely while debugging.","solutions":["Pass api_base explicitly, e.g. 'https://eastus.api.cognitive.microsoft.com' or 'https://eastus.stt.speech.microsoft.com'.","Or export AZURE_SPEECH_API_BASE=<endpoint> in the environment.","Use the region matching your Speech resource; find it on the resource's Overview page in the Azure portal.","In the LiteLLM proxy, set api_base on the model's deployment entry."],"exampleFix":"# before\nresponse = litellm.transcription(model='azure/speech', file=f, api_key=key)\n\n# after\nresponse = litellm.transcription(\n    model='azure/speech', file=f, api_key=key,\n    api_base='https://eastus.stt.speech.microsoft.com',\n)","handlingStrategy":"validation","validationCode":"import os\nfrom urllib.parse import urlparse\n\nbase = os.environ.get('AZURE_SPEECH_API_BASE')\nif not base:\n    raise RuntimeError('Set AZURE_SPEECH_API_BASE (e.g. https://<region>.stt.speech.microsoft.com).')\nhost = urlparse(base).hostname or ''\nassert host.endswith('api.cognitive.microsoft.com') or host.endswith('stt.speech.microsoft.com'), f'Unexpected Speech endpoint: {host}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store the Speech resource endpoint next to the key in the same config source so they are set together.","Include an endpoint-shape assertion in startup health checks."],"tags":["azure","speech","configuration","endpoint","env-vars"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}