BerriAI/litellm · error

ElevenLabs API key is required. Set ELEVENLABS_API_KEY…

Error message

ElevenLabs API key is required. Set ELEVENLABS_API_KEY environment variable.

What it means

Credential guard in the ElevenLabs speech-to-text config: neither an explicit api_key nor the ELEVENLABS_API_KEY secret resolved, so the request to the /v1/speech-to-text endpoint would be unauthorized and fails validation first.

Solutions

  1. Set the ELEVENLABS_API_KEY environment variable before making the call, e.g. export ELEVENLABS_API_KEY=<your-key>.
  2. Alternatively pass the credential directly via the api_key parameter in the litellm call.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/elevenlabs/audio_transcription/transformation.py:181 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/e2c1c1f7cb84cd57. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/elevenlabs/audio_transcription/transformation.py:181

        # ElevenLabs speech-to-text endpoint
        url: Final = f"{api_base}/v1/speech-to-text"

        return url

    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("ELEVENLABS_API_KEY")
        if api_key is None:
            raise ValueError("ElevenLabs API key is required. Set ELEVENLABS_API_KEY environment variable.")

        auth_header: Final = {
            "xi-api-key": api_key,
        }

        headers.update(auth_header)
        return headers

View on GitHub (pinned to 77b7c6c40c)