BerriAI/litellm · error · Exception
Azure api base not found
Error message
Azure api base not found
What it means
The Azure passthrough transformation derives the target URL from an api_base obtained via get_api_base(api_base); if nothing resolves, get_complete_url raises this generic Exception('Azure api base not found'). Because litellm passthrough forwards arbitrary paths to Azure, it must know the resource root URL, and without it the request cannot be routed. Note it is a bare Exception, not a ValueError, so broad handlers will also catch it.
Source
Thrown at litellm/llms/azure/passthrough/transformation.py:35
class AzurePassthroughConfig(BasePassthroughConfig):
def is_streaming_request(self, endpoint: str, request_data: dict) -> bool:
return "stream" in request_data
def get_complete_url(
self,
api_base: str | None,
api_key: str | None,
model: str,
endpoint: str,
request_query_params: dict | None,
litellm_params: dict,
) -> tuple["URL", str]:
base_target_url: Final = self.get_api_base(api_base)
if base_target_url is None:
raise Exception("Azure api base not found")
litellm_metadata: Final = litellm_params.get("litellm_metadata") or {}
model_group: Final = litellm_metadata.get("model_group")
if model_group and model_group in endpoint:
endpoint = endpoint.replace(model_group, model)
complete_url: Final = BaseAzureLLM._get_base_azure_url(
api_base=base_target_url,
litellm_params=litellm_params,
route=endpoint,
default_api_version=litellm_params.get("api_version"),
)
return (
httpx.URL(complete_url),
base_target_url,
)
def validate_environment(View on GitHub (pinned to 6c2dcb801b)
Solutions
- Add api_base: https://<resource>.openai.azure.com to the Azure model's litellm_params in the router config.
- Or set the AZURE_API_BASE environment variable for the proxy process.
- Or set litellm.api_base globally if all Azure traffic shares one resource.
- Restart the proxy after changing config so the model list is reloaded.
Example fix
# before (config.yaml)
model_list:
- model_name: azure-gpt4o
litellm_params:
model: azure/gpt-4o-deployment
api_key: os.environ/AZURE_API_KEY
# after
model_list:
- model_name: azure-gpt4o
litellm_params:
model: azure/gpt-4o-deployment
api_key: os.environ/AZURE_API_KEY
api_base: https://myresource.openai.azure.com Defensive patterns
Strategy: validation
Validate before calling
def validate_azure_passthrough_model(litellm_params: dict) -> None:
import os
base = litellm_params.get('api_base') or os.environ.get('AZURE_API_BASE')
if not base:
raise ValueError('Azure passthrough model config must include api_base') Try / catch
try:
resp = client.azure_passthrough(...)
except Exception as e:
if 'Azure api base not found' in str(e):
raise ValueError('add api_base to the Azure model litellm_params or set AZURE_API_BASE') from e
raise Prevention
- Lint proxy config at startup: every azure/* model must have api_base in litellm_params.
- Use env-var references (os.environ/AZURE_API_BASE) in config.yaml so bases are consistent.
- Note this raises a bare Exception, so match on the message text.
When it happens
Trigger: Using the passthrough endpoint (e.g. /azure/<deployment>/<path>) with no api_base supplied on the router model config, no litellm.api_base global, and no AZURE_API_BASE env var; adding an Azure deployment to the router without an api_base field.
Common situations: Proxy configs where the model_list entry has api_key but omits api_base; assuming passthrough inherits the base from a different provider's config; typos like api_base vs azure_endpoint field names in config files.
Related errors
- api_base is required for Azure AI Studio. Please set the api
- api_base is required for Azure OpenAI calls
- api_base is required for Azure WebSocket
- api_base is required for Azure AVA TTS. Format: https://{reg
- api_base is required for Azure AI Agents. Set it via AZURE_A
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/156e45eb5970422d.
Report an issue: GitHub.