{"record":{"id":"5a26af100abf7f7b","repo":"openai/openai-python","slug":"configure-provider-on-asyncopenai-not-on-asy","errorCode":null,"errorMessage":"Configure `provider` on `AsyncOpenAI`, not on `AsyncAzureOpenAI.with_options()`.","messagePattern":"Configure `provider` on `AsyncOpenAI`, not on `AsyncAzureOpenAI\\.with_options\\(\\)`\\.","errorType":"exception","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"src/openai/lib/azure.py","lineNumber":752,"sourceCode":"        data_residency: DataResidency | None = None,\n        timeout: float | Timeout | None | NotGiven = NOT_GIVEN,\n        http_client: httpx2.AsyncClient | 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 `AsyncOpenAI`, not on `AsyncAzureOpenAI.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":734,"sourceCodeEnd":770,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/azure.py#L734-L770","documentation":"AsyncAzureOpenAI.with_options() rejects the provider option. Providers such as bedrock/vertex are configured on the OpenAI client; Azure routing comes from azure_endpoint instead.","triggerScenarios":"azure_client.with_options(provider=...), or generic kwargs funneled into with_options on an Azure async client.","commonSituations":"Unified client factories passing a shared options object; switching client classes without pruning options.","solutions":["Drop provider from the Azure with_options() call","Use OpenAI(provider=...) if you actually want another provider"],"exampleFix":"# before\nclient = azure_client.with_options(provider=Provider.vertex)\n# after\nclient = openai_client.with_options()","handlingStrategy":"validation","validationCode":"if \"provider\" in opts and isinstance(client, AsyncAzureOpenAI):\n    opts = {k: v for k, v in opts.items() if k != \"provider\"}","typeGuard":"from openai import AsyncAzureOpenAI\ndef is_async_azure(c) -> bool: return isinstance(c, AsyncAzureOpenAI)","tryCatchPattern":null,"preventionTips":["Configure provider only at OpenAI construction time"],"tags":["azure","with-options","invalid-argument","async"],"backgroundTag":"unsupported-client-option","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}