BerriAI/litellm · error · ValueError
api_base is required for Azure AI Agents. Set it via…
Error message
api_base is required for Azure AI Agents. Set it via AZURE_AI_API_BASE env var or api_base parameter.
What it means
Error "api_base is required for Azure AI Agents. Set it via AZURE_AI_API_BASE env var or api_base parameter." thrown in BerriAI/litellm.
Solutions
- Set AZURE_AI_API_BASE or pass api_base for Azure AI Agents.
When it happens
Trigger: Thrown at litellm/llms/azure_ai/agents/transformation.py:163 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/2065fdc0d2a9671e.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/azure_ai/agents/transformation.py:163
api_base: str | None,
api_key: str | None,
model: str,
optional_params: dict,
litellm_params: dict,
stream: bool | None = None,
) -> str:
"""
Get the base URL for Azure AI Agent Service.
The actual endpoint will vary based on the operation:
- /openai/threads for creating threads
- /openai/threads/{thread_id}/messages for adding messages
- /openai/threads/{thread_id}/runs for creating runs
This returns the base URL that will be modified for each operation.
"""
if api_base is None:
raise ValueError(
"api_base is required for Azure AI Agents. Set it via AZURE_AI_API_BASE env var or api_base parameter."
)
# Remove trailing slash if present
api_base = api_base.rstrip("/")
# Return base URL - actual endpoints will be constructed during request
return api_base
def _get_agent_id(self, model: str, optional_params: dict) -> str:
"""
Get the agent ID from model or optional_params.
model format: "azure_ai/agents/<agent_id>" or "agents/<agent_id>" or just "<agent_id>"
"""
agent_id: Final = optional_params.get("agent_id") or optional_params.get("assistant_id")
if agent_id:
return agent_idView on GitHub (pinned to 77b7c6c40c)