{"record":{"id":"1ebe9c87c46066bc","repo":"BerriAI/litellm","slug":"azure-ai-api-key-is-required-please-set-azure-ai","errorCode":null,"errorMessage":"Azure AI API key is required. Please set 'AZURE_AI_API_KEY' or 'litellm.azure_key'","messagePattern":"Azure AI API key is required\\. Please set 'AZURE_AI_API_KEY' or 'litellm\\.azure_key'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/rerank/transformation.py","lineNumber":72,"sourceCode":"                api_base=str(original_url.copy_with(path=normalized_path or \"/\")),\n                ending_path=\"/rerank\",\n            )\n\n        # Backwards compatible default: Azure AI rerank was originally exposed under /v1/rerank\n        return _add_path_to_api_base(api_base=api_base, ending_path=\"/v1/rerank\")\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        api_key: str | None = None,\n        optional_params: dict | None = None,\n    ) -> dict:\n        if api_key is None:\n            api_key = get_secret_str(\"AZURE_AI_API_KEY\") or litellm.azure_key\n\n        if api_key is None:\n            raise ValueError(\"Azure AI API key is required. Please set 'AZURE_AI_API_KEY' or 'litellm.azure_key'\")\n\n        default_headers: Final = {\n            \"Authorization\": f\"Bearer {api_key}\",\n            \"accept\": \"application/json\",\n            \"content-type\": \"application/json\",\n        }\n\n        # If 'Authorization' is provided in headers, it overrides the default.\n        if \"Authorization\" in headers:\n            default_headers[\"Authorization\"] = headers[\"Authorization\"]\n\n        # Merge other headers, overriding any default ones except Authorization\n        return {**default_headers, **headers}\n\n    def transform_rerank_response(\n        self,\n        model: str,\n        raw_response: httpx.Response,","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/azure_ai/rerank/transformation.py#L54-L90","documentation":"Error \"Azure AI API key is required. Please set 'AZURE_AI_API_KEY' or 'litellm.azure_key'\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/azure_ai/rerank/transformation.py:72 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set AZURE_AI_API_KEY, litellm.azure_key, or pass api_key."],"exampleFix":null,"handlingStrategy":null,"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"}