BerriAI/litellm · error · ValueError
Azure AI API key is required for model {model}. Set AZURE_AI
Error message
Azure AI API key is required for model {model}. Set AZURE_AI_API_KEY environment variable or pass api_key parameter. What it means
Error "Azure AI API key is required for model {model}. Set AZURE_AI_API_KEY environment variable or pass api_key parameter." thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/azure_ai/image_edit/transformation.py:38
with image files and prompt.
"""
def validate_environment(
self,
headers: dict,
model: str,
api_key: str | None = None,
litellm_params: dict | None = None,
api_base: str | None = None,
) -> dict:
"""
Validate Azure AI Foundry environment and set up authentication
Uses Api-Key header format
"""
api_key = AzureFoundryModelInfo.get_api_key(api_key)
if not api_key:
raise ValueError(
f"Azure AI API key is required for model {model}. Set AZURE_AI_API_KEY environment variable or pass api_key parameter."
)
headers.update(
{
"Api-Key": api_key, # Azure AI Foundry uses Api-Key header format
}
)
return headers
def get_complete_url(
self,
model: str,
api_base: str | None,
litellm_params: dict,
) -> str:
"""
Constructs a complete URL for Azure AI Foundry image edits API request.View on GitHub (pinned to 6c2dcb801b)
Solutions
- Set AZURE_AI_API_KEY or pass api_key.
When it happens
Trigger: Thrown at litellm/llms/azure_ai/image_edit/transformation.py:38 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/304809156449e680.
Report an issue: GitHub.