BerriAI/litellm · error · ValueError
Missing Azure AI API Key - A call is being made to Azure AI…
Error message
Missing Azure AI API Key - A call is being made to Azure AI but no key is set either in the environment variables or via params
What it means
Error "Missing Azure AI API Key - A call is being made to Azure AI but no key is set either in the environment variables or via params" thrown in BerriAI/litellm.
Solutions
- Set AZURE_AI_API_KEY or pass api_key.
When it happens
Trigger: Thrown at litellm/llms/azure_ai/ocr/transformation.py:57 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/82f8c33bcf2af705.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/azure_ai/ocr/transformation.py:57
self,
headers: dict,
model: str,
api_key: str | None = None,
api_base: str | None = None,
litellm_params: dict | None = None,
**kwargs,
) -> dict:
"""
Validate environment and return headers for Azure AI OCR.
Azure AI uses Bearer token authentication with AZURE_AI_API_KEY.
"""
# Get API key from environment if not provided
if api_key is None:
api_key = get_secret_str(AZURE_AI_OCR_API_KEY_ENV_VAR)
if api_key is None:
raise ValueError(
"Missing Azure AI API Key - A call is being made to Azure AI but no key is set either in the environment variables or via params"
)
# Validate API base is provided
if api_base is None:
api_base = get_secret_str("AZURE_AI_API_BASE")
if api_base is None:
raise ValueError(
"Missing Azure AI API Base - Set AZURE_AI_API_BASE environment variable or pass api_base parameter"
)
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
**headers,
}
View on GitHub (pinned to 77b7c6c40c)