BerriAI/litellm · error · ValueError
Azure AI API key is required. Please set 'AZURE_AI_API_KEY'…
Error message
Azure AI API key is required. Please set 'AZURE_AI_API_KEY' or 'litellm.azure_key'
What it means
Error "Azure AI API key is required. Please set 'AZURE_AI_API_KEY' or 'litellm.azure_key'" thrown in BerriAI/litellm.
Solutions
- Set AZURE_AI_API_KEY, litellm.azure_key, or pass api_key.
When it happens
Trigger: Thrown at litellm/llms/azure_ai/rerank/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/1ebe9c87c46066bc.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/azure_ai/rerank/transformation.py:72
api_base=str(original_url.copy_with(path=normalized_path or "/")),
ending_path="/rerank",
)
# Backwards compatible default: Azure AI rerank was originally exposed under /v1/rerank
return _add_path_to_api_base(api_base=api_base, ending_path="/v1/rerank")
def validate_environment(
self,
headers: dict,
model: str,
api_key: str | None = None,
optional_params: dict | None = None,
) -> dict:
if api_key is None:
api_key = get_secret_str("AZURE_AI_API_KEY") or litellm.azure_key
if api_key is None:
raise ValueError("Azure AI API key is required. Please set 'AZURE_AI_API_KEY' or 'litellm.azure_key'")
default_headers: Final = {
"Authorization": f"Bearer {api_key}",
"accept": "application/json",
"content-type": "application/json",
}
# If 'Authorization' is provided in headers, it overrides the default.
if "Authorization" in headers:
default_headers["Authorization"] = headers["Authorization"]
# Merge other headers, overriding any default ones except Authorization
return {**default_headers, **headers}
def transform_rerank_response(
self,
model: str,
raw_response: httpx.Response,View on GitHub (pinned to 77b7c6c40c)