{"record":{"id":"140c61f734ef647c","repo":"openai/openai-python","slug":"base-url-and-azure-endpoint-are-mutually-exclusive","errorCode":null,"errorMessage":"base_url and azure_endpoint are mutually exclusive","messagePattern":"base_url and azure_endpoint are mutually exclusive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/lib/azure.py","lineNumber":334,"sourceCode":"        else:\n            default_query = {**default_query, \"api-version\": api_version}\n\n        if base_url is None:\n            if azure_endpoint is None:\n                azure_endpoint = os.environ.get(\"AZURE_OPENAI_ENDPOINT\")\n\n            if azure_endpoint is None:\n                raise ValueError(\n                    \"Must provide one of the `base_url` or `azure_endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable\"\n                )\n\n            if azure_deployment is not None:\n                base_url = f\"{azure_endpoint.rstrip('/')}/openai/deployments/{azure_deployment}\"\n            else:\n                base_url = f\"{azure_endpoint.rstrip('/')}/openai\"\n        else:\n            if azure_endpoint is not None:\n                raise ValueError(\"base_url and azure_endpoint are mutually exclusive\")\n\n        if api_key is None:\n            # define a sentinel value to avoid any typing issues\n            api_key = API_KEY_SENTINEL\n\n        super().__init__(\n            api_key=api_key,\n            admin_api_key=admin_api_key,\n            organization=organization,\n            project=project,\n            webhook_secret=webhook_secret,\n            base_url=base_url,\n            timeout=timeout,\n            max_retries=max_retries,\n            default_headers=default_headers,\n            default_query=default_query,\n            http_client=http_client,\n            websocket_base_url=websocket_base_url,","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/azure.py#L316-L352","documentation":"AzureOpenAI cannot derive its URL from two conflicting sources. Supplying both base_url and azure_endpoint is ambiguous (they overlap in purpose), so the constructor raises ValueError immediately.","triggerScenarios":"Calling AzureOpenAI(base_url=..., azure_endpoint=...) in the same constructor; often happens when base_url is set from a config object while azure_endpoint is hardcoded.","commonSituations":"Copying sample code that sets base_url while env/config also sets azure_endpoint; refactoring from OpenAI to AzureOpenAI and leaving base_url in place.","solutions":["Remove one of the two arguments — keep azure_endpoint for standard Azure usage","If you truly need a custom full URL, pass only base_url and drop azure_endpoint"],"exampleFix":"# before\nclient = AzureOpenAI(base_url=\"https://res.openai.azure.com/openai\", azure_endpoint=\"https://res.openai.azure.com\")\n# after\nclient = AzureOpenAI(azure_endpoint=\"https://res.openai.azure.com\")","handlingStrategy":"validation","validationCode":"if base_url and azure_endpoint:\n    raise ValueError(\"pass only one of base_url or azure_endpoint\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint constructor kwargs in shared factories","Keep Azure client construction in one place"],"tags":["azure","configuration","mutually-exclusive"],"backgroundTag":"conflicting-configuration-options","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}