{"record":{"id":"b529afcac09759f5","repo":"BerriAI/litellm","slug":"no-api-base-provided-for-azure-openai-llm-provider","errorCode":null,"errorMessage":"No API Base provided for Azure OpenAI LLM provider. Set 'AZURE_API_BASE' in .env","messagePattern":"No API Base provided for Azure OpenAI LLM provider\\. Set 'AZURE_API_BASE' in \\.env","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/main.py","lineNumber":6170,"sourceCode":"\n        if azure is True or custom_llm_provider == \"azure\":\n            # azure configs\n\n            api_base = api_base or litellm.api_base or get_secret_str(\"AZURE_API_BASE\")\n\n            api_version = (\n                api_version\n                or litellm.api_version\n                or get_secret_str(\"AZURE_API_VERSION\")\n                or litellm.AZURE_DEFAULT_API_VERSION\n            )\n\n            azure_ad_token: Final = optional_params.pop(\"azure_ad_token\", None) or get_secret_str(\"AZURE_AD_TOKEN\")\n\n            api_key = api_key or litellm.api_key or litellm.azure_key or get_secret_str(\"AZURE_API_KEY\")\n\n            if api_base is None:\n                raise ValueError(\"No API Base provided for Azure OpenAI LLM provider. Set 'AZURE_API_BASE' in .env\")\n\n            ## EMBEDDING CALL\n            response = azure_chat_completions.embedding(\n                model=model,\n                input=input,\n                api_base=api_base,\n                api_key=api_key,\n                api_version=api_version,\n                azure_ad_token=azure_ad_token,\n                azure_ad_token_provider=azure_ad_token_provider,\n                logging_obj=logging,\n                timeout=timeout,\n                model_response=EmbeddingResponse(),\n                optional_params=optional_params,\n                client=client,\n                aembedding=aembedding,\n                max_retries=max_retries,\n                headers=headers or extra_headers,","sourceCodeStart":6152,"sourceCodeEnd":6188,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/main.py#L6152-L6188","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'))\""],"exampleFix":"# before\nos.environ[\"AZURE_API_KEY\"] = key\nresp = litellm.embedding(model=\"azure/my-deploy\", input=[\"hi\"])\n\n# after\nos.environ[\"AZURE_API_KEY\"] = key\nos.environ[\"AZURE_API_BASE\"] = \"https://my-resource.openai.azure.com/\"\nresp = litellm.embedding(model=\"azure/my-deploy\", input=[\"hi\"])","handlingStrategy":"validation","validationCode":"import os\n\napi_base = os.environ.get(\"AZURE_API_BASE\") or litellm.api_base\nif not api_base:\n    raise SystemExit(\"AZURE_API_BASE is not set; refusing to call azure embeddings\")","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.embedding(model=\"azure/deploy\", input=[\"hi\"])\nexcept ValueError as e:\n    if \"No API Base\" in str(e):\n        # config problem, not transient: surface to operator\n        raise","preventionTips":["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"],"tags":["azure","embedding","env-var","api-base","litellm"],"backgroundTag":"missing-env-var","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}