{"record":{"id":"e2c1c1f7cb84cd57","repo":"BerriAI/litellm","slug":"elevenlabs-api-key-is-required-set-elevenlabs-api","errorCode":null,"errorMessage":"ElevenLabs API key is required. Set ELEVENLABS_API_KEY environment variable.","messagePattern":"ElevenLabs API key is required\\. Set ELEVENLABS_API_KEY environment variable\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"litellm/llms/elevenlabs/audio_transcription/transformation.py","lineNumber":181,"sourceCode":"\n        # ElevenLabs speech-to-text endpoint\n        url: Final = f\"{api_base}/v1/speech-to-text\"\n\n        return url\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        api_key = api_key or get_secret_str(\"ELEVENLABS_API_KEY\")\n        if api_key is None:\n            raise ValueError(\"ElevenLabs API key is required. Set ELEVENLABS_API_KEY environment variable.\")\n\n        auth_header: Final = {\n            \"xi-api-key\": api_key,\n        }\n\n        headers.update(auth_header)\n        return headers\n","sourceCodeStart":163,"sourceCodeEnd":189,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/elevenlabs/audio_transcription/transformation.py#L163-L189","documentation":"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.","triggerScenarios":"Thrown at litellm/llms/elevenlabs/audio_transcription/transformation.py:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the ELEVENLABS_API_KEY environment variable before making the call, e.g. export ELEVENLABS_API_KEY=<your-key>.","Alternatively pass the credential directly via the api_key parameter in the litellm call."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}