openai/openai-python · error · OpenAIError
`data_residency` is only supported by OpenAI clients
Error message
`data_residency` is only supported by OpenAI clients
What it means
`BedrockOpenAI.with_options()`/`copy()` rejects the `data_residency` parameter. Data residency routing is a first-party OpenAI API feature configured on `OpenAI` clients, not on Bedrock clients.
Source
Thrown at src/openai/lib/bedrock.py:566
aws_credentials_provider: AwsCredentialsProvider | None = None,
organization: str | None = None,
project: str | None = None,
webhook_secret: str | None = None,
websocket_base_url: str | httpx2.URL | None = None,
base_url: str | httpx2.URL | None | NotGiven = NOT_GIVEN,
data_residency: DataResidency | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx2.Client | None = None,
max_retries: int | NotGiven = NOT_GIVEN,
default_headers: Mapping[str, str] | None = None,
set_default_headers: Mapping[str, str] | None = None,
default_query: Mapping[str, object] | None = None,
set_default_query: Mapping[str, object] | None = None,
_enforce_credentials: bool | None = None,
_extra_kwargs: Mapping[str, Any] = {},
) -> Self:
if data_residency is not None:
raise OpenAIError("`data_residency` is only supported by OpenAI clients")
base_url = None if isinstance(base_url, NotGiven) else base_url
if callable(api_key):
raise OpenAIError("Pass refreshable Bedrock credentials via `bedrock_token_provider`, not `api_key`.")
if not isinstance(provider, NotGiven):
raise OpenAIError("Configure `provider` on `OpenAI`, not on `BedrockOpenAI.with_options()`.")
if admin_api_key is not None or workload_identity is not None:
raise OpenAIError("BedrockOpenAI only supports Bedrock bearer token or AWS credential authentication.")
if default_headers is not None and set_default_headers is not None:
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
if default_query is not None and set_default_query is not None:
raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
headers = self._custom_headers
if default_headers is not None:
headers = {**headers, **default_headers}
elif set_default_headers is not None:
headers = set_default_headers
params = self._custom_queryView on GitHub (pinned to 9917c6e28e)
Solutions
- Remove `data_residency` from Bedrock client calls; residency for Bedrock is governed by the AWS region
- Construct a separate `OpenAI(..., data_residency='eu')` client if you need first-party data residency
Example fix
# before eu = bedrock_client.with_options(data_residency='eu') # after eu = bedrock_client # Bedrock residency follows the aws_region you configure
Defensive patterns
Strategy: validation
Validate before calling
kwargs.pop('data_residency', None) # before calling bedrock with_options Prevention
- Keep OpenAI-only options out of shared with_options wrappers
- Branch client factories by client type
When it happens
Trigger: `bedrock_client.with_options(data_residency='eu')` or `BedrockOpenAI(..., data_residency=...)` via copy on the sync client.
Common situations: Shared helper functions that call `with_options(**kwargs)` for both OpenAI and Bedrock clients; migrating EU-residency setup code from `OpenAI` to a Bedrock deployment.
Related errors
- Configure `provider` on `OpenAI`, not on `BedrockOpenAI.with
- BedrockOpenAI only supports Bedrock bearer token or AWS cred
- Configure `provider` on `AsyncOpenAI`, not on `AsyncBedrockO
- AsyncBedrockOpenAI only supports Bedrock bearer token or AWS
- The `default_headers` and `set_default_headers` arguments ar
AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28).
Data as JSON: /api/errors/ed2314a90923f0d3.
Report an issue: GitHub.