BerriAI/litellm · error · AzureSpeechAudioTranscriptionException

api_key is required for Azure AI Speech transcription.

Error message

api_key is required for Azure AI Speech transcription.

What it means

Error "api_key is required for Azure AI Speech transcription." thrown in BerriAI/litellm.

Solutions

  1. Set AZURE_API_KEY or pass api_key for the Azure AI Speech transcription call.

When it happens

Trigger: Thrown at litellm/llms/azure/audio_transcription/transformation.py:72 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/59aefb3363e5745c. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/azure/audio_transcription/transformation.py:72

        supported_params: Final = self.get_supported_openai_params(model=model)
        for key, value in non_default_params.items():
            if key in supported_params:
                optional_params[key] = value
        return optional_params

    def validate_environment(
        self,
        headers: dict,
        model: str,
        messages: list[AllMessageValues],
        optional_params: dict,
        litellm_params: dict,
        api_key: str | None = None,
        api_base: str | None = None,
    ) -> dict:
        api_key = api_key or get_secret_str("AZURE_SPEECH_API_KEY")
        if not api_key:
            raise AzureSpeechAudioTranscriptionException(
                message="api_key is required for Azure AI Speech transcription.",
                status_code=401,
            )

        validated_headers: Final = headers.copy()
        validated_headers["Ocp-Apim-Subscription-Key"] = api_key
        validated_headers["Content-Type"] = validated_headers.get("Content-Type", "audio/wav")
        validated_headers["Accept"] = "application/json"
        return validated_headers

    def get_complete_url(
        self,
        api_base: str | None,
        api_key: str | None,
        model: str,
        optional_params: dict,
        litellm_params: dict,
        stream: bool | None = None,

View on GitHub (pinned to 77b7c6c40c)