{"record":{"id":"11fe801ec6fc566c","repo":"BerriAI/litellm","slug":"missing-azure-api-base-please-set-api-base-or","errorCode":null,"errorMessage":"Missing Azure API Base - Please set `api_base` or `AZURE_API_BASE` environment variable. Expected format: https://<resource-name>.services.ai.azure.com/anthropic","messagePattern":"Missing Azure API Base - Please set `api_base` or `AZURE_API_BASE` environment variable\\. Expected format: https://<resource-name>\\.services\\.ai\\.azure\\.com/anthropic","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/anthropic/messages_transformation.py","lineNumber":92,"sourceCode":"\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        api_key: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict,\n        stream: bool | None = None,\n    ) -> str:\n        \"\"\"\n        Get the complete URL for Azure Anthropic /v1/messages endpoint.\n        Azure Foundry endpoint format: https://<resource-name>.services.ai.azure.com/anthropic/v1/messages\n        \"\"\"\n        from litellm.secret_managers.main import get_secret_str\n\n        api_base = api_base or get_secret_str(\"AZURE_API_BASE\")\n        if api_base is None:\n            raise ValueError(\n                \"Missing Azure API Base - Please set `api_base` or `AZURE_API_BASE` environment variable. \"\n                \"Expected format: https://<resource-name>.services.ai.azure.com/anthropic\"\n            )\n\n        # Ensure the URL ends with /v1/messages\n        api_base = api_base.rstrip(\"/\")\n        if api_base.endswith(\"/v1/messages\") or api_base.endswith(\"/anthropic/v1/messages\"):\n            # Already correct\n            pass\n        else:\n            # Check if /anthropic is already in the path\n            if \"/anthropic\" in api_base:\n                # /anthropic exists, ensure we end with /anthropic/v1/messages\n                # Extract the base URL up to and including /anthropic\n                parts: Final = api_base.split(\"/anthropic\", 1)\n                api_base = parts[0] + \"/anthropic\"\n            else:\n                # /anthropic not in path, add it","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/anthropic/messages_transformation.py#L74-L110","documentation":"For the Azure Anthropic messages route, LiteLLM constructs https://<resource>.services.ai.azure.com/anthropic/v1/messages from api_base (parameter) or the AZURE_API_BASE environment variable. If both are absent it raises this ValueError, including the expected URL shape, before any network call. Note this route uses AZURE_API_BASE (the Azure OpenAI variable), not AZURE_AI_API_BASE.","triggerScenarios":"Calling the azure anthropic messages route with neither api_base on the request/deployment nor AZURE_API_BASE exported; in litellm proxy, forgetting litellm_params.api_base on the model entry; env var present in shell but the proxy runs under systemd/docker without it.","commonSituations":"Mixed Azure setups where AZURE_AI_API_BASE was set instead of AZURE_API_BASE; moving from direct Anthropic (ANTHROPIC_API_BASE) to Azure-hosted Claude and forgetting the Foundry endpoint; proxy config committed without the base URL because it 'worked locally'.","solutions":["Set api_base on the call or deployment to your Foundry anthropic endpoint: https://<resource>.services.ai.azure.com/anthropic — litellm appends /v1/messages if missing.","Or export AZURE_API_BASE with that value in the environment of the litellm process.","In proxy config, put api_base inside the model's litellm_params block.","Verify with curl that the endpoint answers before retrying through litellm."],"exampleFix":"# before (proxy config missing base)\nmodel_list:\n  - model_name: claude\n    litellm_params:\n      model: azure/claude-3-5-sonnet\n\n# after\nmodel_list:\n  - model_name: claude\n    litellm_params:\n      model: azure/claude-3-5-sonnet\n      api_base: https://myfoundry.services.ai.azure.com/anthropic\n      api_key: os.environ/AZURE_API_KEY","handlingStrategy":"validation","validationCode":"import os\n\ndef azure_anthropic_base() -> str:\n    base = os.getenv('AZURE_API_BASE')  # note: NOT AZURE_AI_API_BASE\n    if not base:\n        raise RuntimeError('Set AZURE_API_BASE to https://<resource>.services.ai.azure.com/anthropic')\n    return base","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model='azure/claude-...', api_base=azure_anthropic_base(), ...)\nexcept ValueError as e:\n    if 'Missing Azure API Base' in str(e):\n        raise ConfigurationError(str(e)) from e\n    raise","preventionTips":["Pin the anthropic base URL in one config constant shared by all Claude-on-Azure calls.","Remember this route reads AZURE_API_BASE, unlike the agents route's AZURE_AI_API_BASE.","Add config linting that rejects azure/anthropic deployments lacking api_base."],"tags":["azure","anthropic","configuration","api-base","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}