{"record":{"id":"f51e8b5246839dd1","repo":"microsoft/graphrag","slug":"api-base-must-be-specified-with-the-azure-model","errorCode":null,"errorMessage":"api_base must be specified with the 'azure' model provider.","messagePattern":"api_base must be specified with the 'azure' model provider\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag-llm/graphrag_llm/config/model_config.py","lineNumber":92,"sourceCode":"        default=None,\n        description=\"Configuration for the rate limit behavior.\",\n    )\n\n    metrics: MetricsConfig | None = Field(\n        default_factory=MetricsConfig,\n        description=\"Specify and configure the metric services.\",\n    )\n\n    mock_responses: list[str] | list[float] = Field(\n        default_factory=list,\n        description=\"List of mock responses for testing.\",\n    )\n\n    def _validate_lite_llm_config(self) -> None:\n        \"\"\"Validate LiteLLM specific configuration.\"\"\"\n        if self.model_provider == \"azure\" and not self.api_base:\n            msg = \"api_base must be specified with the 'azure' model provider.\"\n            raise ValueError(msg)\n\n        if self.model_provider != \"azure\" and self.azure_deployment_name is not None:\n            msg = \"azure_deployment_name should not be specified for non-Azure model providers.\"\n            raise ValueError(msg)\n\n        if self.auth_method == AuthMethod.AzureManagedIdentity:\n            if self.api_key is not None:\n                msg = \"api_key should not be set when using Azure Managed Identity.\"\n                raise ValueError(msg)\n        elif not self.api_key:\n            msg = \"api_key must be set when auth_method=api_key.\"\n            raise ValueError(msg)\n\n    @model_validator(mode=\"after\")\n    def _validate_model(self):\n        \"\"\"Validate model configuration after initialization.\"\"\"\n        if self.type == LLMProviderType.LiteLLM:\n            self._validate_lite_llm_config()","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag-llm/graphrag_llm/config/model_config.py#L74-L110","documentation":"Thrown by ModelConfig validation when model_provider is set to 'azure' but api_base is empty. LiteLLM's Azure backend requires an endpoint URL (e.g. https://<resource>.openai.azure.com) to route requests, so the config is rejected at construction time.","triggerScenarios":"Creating a ModelConfig(model_provider=\"azure\", ...) via Pydantic validation without an api_base field, or loading settings.yaml where azure is set but api_base is missing/None.","commonSituations":"Migrating from openai provider to azure and forgetting the endpoint; env var for api_base (e.g. GRAPHRAG_API_BASE) unset so the settings loader passes None; copy-pasted config missing the base URL.","solutions":["Set api_base to your Azure OpenAI endpoint, e.g. api_base: \"https://myresource.openai.azure.com\" in settings or ModelConfig(api_base=...)","If the value comes from an env var, verify it is exported and picked up by the settings loader before constructing ModelConfig","If you did not intend Azure, change model_provider back to 'openai' (or another LiteLLM provider)"],"exampleFix":"# before\nconfig = ModelConfig(model_provider=\"azure\", model=\"gpt-4o\", api_key=\"...\")\n# after\nconfig = ModelConfig(model_provider=\"azure\", model=\"gpt-4o\", api_key=\"...\", api_base=\"https://myresource.openai.azure.com\")","handlingStrategy":"validation","validationCode":"provider = cfg.get(\"model_provider\")\nif provider == \"azure\" and not cfg.get(\"api_base\"):\n    raise SystemExit(\"azure provider requires api_base (https://<resource>.openai.azure.com)\")","typeGuard":null,"tryCatchPattern":"try:\n    ModelConfig(**cfg)\nexcept ValueError as e:\n    if \"api_base must be specified\" in str(e):\n        cfg[\"api_base\"] = os.environ[\"AZURE_OPENAI_ENDPOINT\"]\n        model = ModelConfig(**cfg)\n    else:\n        raise","preventionTips":["Always define api_base next to model_provider: azure in settings templates","Add a CI config schema check that runs ModelConfig validation on settings.yaml","Use env var lints (direnv/Makefile) that fail fast when AZURE endpoint vars are missing"],"tags":["azure","litellm","config-validation","missing-endpoint"],"backgroundTag":"missing-required-config-field","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}