BerriAI/litellm · error · ValueError
Azure AI API Base is required. api_base=None. Set in call…
Error message
Azure AI API Base is required. api_base=None. Set in call or via `AZURE_AI_API_BASE` env var.
What it means
Error "Azure AI API Base is required. api_base=None. Set in call or via `AZURE_AI_API_BASE` env var." thrown in BerriAI/litellm.
Solutions
- Set AZURE_AI_API_BASE or pass api_base for rerank.
When it happens
Trigger: Thrown at litellm/llms/azure_ai/rerank/transformation.py:29 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/aafb658d5996e7e3.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/azure_ai/rerank/transformation.py:29
from litellm.llms.cohere.rerank.transformation import CohereRerankConfig
from litellm.secret_managers.main import get_secret_str
from litellm.types.utils import RerankResponse
from litellm.utils import _add_path_to_api_base
class AzureAIRerankConfig(CohereRerankConfig):
"""
Azure AI Rerank - Follows the same Spec as Cohere Rerank
"""
def get_complete_url(
self,
api_base: str | None,
model: str,
optional_params: dict | None = None,
) -> str:
if api_base is None:
raise ValueError(
"Azure AI API Base is required. api_base=None. Set in call or via `AZURE_AI_API_BASE` env var."
)
original_url: Final = httpx.URL(api_base)
if not original_url.is_absolute_url:
raise ValueError(
"Azure AI API Base must be an absolute URL including scheme (e.g. "
"'https://<resource>.services.ai.azure.com'). "
f"Got api_base={api_base!r}."
)
normalized_path: Final = original_url.path.rstrip("/")
# Allow callers to pass either full v1/v2 rerank endpoints:
# - https://<resource>.services.ai.azure.com/v1/rerank
# - https://<resource>.services.ai.azure.com/providers/cohere/v2/rerank
if normalized_path.endswith("/v1/rerank") or normalized_path.endswith("/v2/rerank"):
return str(original_url.copy_with(path=normalized_path or "/"))
# If callers pass just the version path (e.g. ".../v2" or ".../providers/cohere/v2"), append "/rerank"View on GitHub (pinned to 77b7c6c40c)