{"record":{"id":"bbb59cd97b8d8e18","repo":"openai/openai-python","slug":"configure-provider-on-openai-not-on-azureope","errorCode":null,"errorMessage":"Configure `provider` on `OpenAI`, not on `AzureOpenAI.with_options()`.","messagePattern":"Configure `provider` on `OpenAI`, not on `AzureOpenAI\\.with_options\\(\\)`\\.","errorType":"exception","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"src/openai/lib/azure.py","lineNumber":400,"sourceCode":"        data_residency: DataResidency | None = None,\n        timeout: float | Timeout | None | NotGiven = NOT_GIVEN,\n        http_client: httpx2.Client | None = None,\n        max_retries: int | NotGiven = NOT_GIVEN,\n        default_headers: Mapping[str, str] | None = None,\n        set_default_headers: Mapping[str, str] | None = None,\n        default_query: Mapping[str, object] | None = None,\n        set_default_query: Mapping[str, object] | None = None,\n        _enforce_credentials: bool | None = None,\n        _extra_kwargs: Mapping[str, Any] = {},\n    ) -> Self:\n        \"\"\"\n        Create a new client instance re-using the same options given to the current client with optional overriding.\n        \"\"\"\n        if data_residency is not None:\n            raise OpenAIError(\"`data_residency` is only supported by OpenAI clients\")\n        base_url = None if isinstance(base_url, NotGiven) else base_url\n        if not isinstance(provider, NotGiven):\n            raise OpenAIError(\"Configure `provider` on `OpenAI`, not on `AzureOpenAI.with_options()`.\")\n        if is_x509_workload_identity(workload_identity):\n            raise OpenAIError(\"X.509 workload identity is not supported by Azure clients\")\n\n        api_key, azure_ad_token, azure_ad_token_provider = _copy_azure_auth(\n            api_key,\n            azure_ad_token,\n            azure_ad_token_provider,\n            current_api_key=self._api_key_provider or self.api_key,\n            current_token=self._azure_ad_token,\n            current_provider=self._azure_ad_token_provider,\n        )\n\n        return super().copy(\n            api_key=api_key,\n            admin_api_key=admin_api_key,\n            workload_identity=workload_identity,\n            organization=organization,\n            project=project,","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/azure.py#L382-L418","documentation":"AzureOpenAI.with_options() rejects the provider option because providers (like bedrock/vertex) are configured on the OpenAI client, not on Azure clients. Azure routing is determined by azure_endpoint/base_url instead.","triggerScenarios":"Calling AzureOpenAI(...).with_options(provider=Provider.bedrock) or funneling generic kwargs into with_options on an Azure client.","commonSituations":"Generic factory code that applies a shared options dict to whichever client it receives; switching from OpenAI(provider=...) to AzureOpenAI without dropping provider.","solutions":["Remove provider from the with_options() call for Azure clients","If you need a non-Azure provider, construct OpenAI(provider=...) instead"],"exampleFix":"# before\nclient = azure_client.with_options(provider=Provider.bedrock)\n# after\nclient = openai_client.with_options()","handlingStrategy":"validation","validationCode":"opts.pop(\"provider\", None) if isinstance(client, AzureOpenAI) else opts\nclient.with_options(**opts)","typeGuard":"from openai import AzureOpenAI\ndef is_azure_client(c) -> bool: return isinstance(c, AzureOpenAI)","tryCatchPattern":null,"preventionTips":["Only pass provider when constructing OpenAI","Validate kwargs against the target client's signature in factories"],"tags":["azure","with-options","invalid-argument"],"backgroundTag":"unsupported-client-option","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}