BerriAI/litellm · error · ValueError
No API Base provided for Azure OpenAI LLM provider. Set 'AZU
Error message
No API Base provided for Azure OpenAI LLM provider. Set 'AZURE_API_BASE' in .env
What it means
Azure OpenAI embeddings must be sent to your resource's endpoint. litellm resolves it from the api_base kwarg, litellm.api_base, or the AZURE_API_BASE environment variable; when all are unset it raises this ValueError before any network call is made.
Source
Thrown at litellm/main.py:6170
if azure is True or custom_llm_provider == "azure":
# azure configs
api_base = api_base or litellm.api_base or get_secret_str("AZURE_API_BASE")
api_version = (
api_version
or litellm.api_version
or get_secret_str("AZURE_API_VERSION")
or litellm.AZURE_DEFAULT_API_VERSION
)
azure_ad_token: Final = optional_params.pop("azure_ad_token", None) or get_secret_str("AZURE_AD_TOKEN")
api_key = api_key or litellm.api_key or litellm.azure_key or get_secret_str("AZURE_API_KEY")
if api_base is None:
raise ValueError("No API Base provided for Azure OpenAI LLM provider. Set 'AZURE_API_BASE' in .env")
## EMBEDDING CALL
response = azure_chat_completions.embedding(
model=model,
input=input,
api_base=api_base,
api_key=api_key,
api_version=api_version,
azure_ad_token=azure_ad_token,
azure_ad_token_provider=azure_ad_token_provider,
logging_obj=logging,
timeout=timeout,
model_response=EmbeddingResponse(),
optional_params=optional_params,
client=client,
aembedding=aembedding,
max_retries=max_retries,
headers=headers or extra_headers,View on GitHub (pinned to 77b7c6c40c)
Solutions
- export AZURE_API_BASE=https://<your-resource>.openai.azure.com/ and confirm the process sees it
- Or pass it per call: litellm.embedding(model='azure/<deploy>', input=[...], api_base='https://<resource>.openai.azure.com/')
- Or set litellm.api_base once if every call targets the same resource
- Sanity check: python -c "import os; print(os.environ.get('AZURE_API_BASE'))"
Example fix
# before os.environ["AZURE_API_KEY"] = key resp = litellm.embedding(model="azure/my-deploy", input=["hi"]) # after os.environ["AZURE_API_KEY"] = key os.environ["AZURE_API_BASE"] = "https://my-resource.openai.azure.com/" resp = litellm.embedding(model="azure/my-deploy", input=["hi"])
Defensive patterns
Strategy: validation
Validate before calling
import os
api_base = os.environ.get("AZURE_API_BASE") or litellm.api_base
if not api_base:
raise SystemExit("AZURE_API_BASE is not set; refusing to call azure embeddings") Try / catch
try:
resp = litellm.embedding(model="azure/deploy", input=["hi"])
except ValueError as e:
if "No API Base" in str(e):
# config problem, not transient: surface to operator
raise Prevention
- Centralize Azure config (key + base + version) in one settings module loaded at startup
- Add startup assertions for AZURE_API_BASE / AZURE_API_KEY in Azure-dependent services
- Load .env with python-dotenv before importing litellm
When it happens
Trigger: litellm.embedding(model='azure/<deployment>', input=[...]) (or custom_llm_provider='azure') with no api_base kwarg, no litellm.api_base, and AZURE_API_BASE absent from the environment.
Common situations: Fresh Azure setup where only AZURE_API_KEY was configured; the variable misnamed AZURE_OPENAI_API_BASE or OPENAI_API_BASE; .env not loaded before import; container/CI dropping env vars.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- api_base is required for Azure OpenAI LLM provider. Either s
- Azure AI Agents requests require an api_base. Set `api_base`
- Azure Anthropic requests require an api_base. Set `api_base`
- api_base is required for A2A provider. Either provide api_ba
- api_base is required for triton. Please pass `api_base`
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/b529afcac09759f5.
Report an issue: GitHub.