openai/openai-python · error · OpenAIError
The Bedrock `endpoint` must be either `mantle` or `runtime`.
Error message
The Bedrock `endpoint` must be either `mantle` or `runtime`.
What it means
The `bedrock()` provider constructor only accepts the endpoint names `mantle` or `runtime` (or None for auto-detection). Any other string, including case variants like `Mantle` or full URLs, is rejected immediately with OpenAIError before any client is built.
Source
Thrown at src/openai/providers/bedrock.py:399
def bedrock(
*,
endpoint: BedrockEndpoint | None = None,
region: str | None = None,
base_url: str | httpx2.URL | None | NotGiven = NOT_GIVEN,
api_key: str | None | NotGiven = NOT_GIVEN,
token_provider: BedrockTokenProvider | None = None,
access_key_id: str | None = None,
secret_access_key: str | None = None,
session_token: str | None = None,
profile: str | None = None,
credential_provider: AwsCredentialsProvider | None = None,
) -> _Provider:
"""Configure the standard OpenAI client for Amazon Bedrock Mantle or Runtime."""
if endpoint is not None and endpoint not in {"mantle", "runtime"}:
raise OpenAIError("The Bedrock `endpoint` must be either `mantle` or `runtime`.")
normalized_region = _normalize_optional_string(region)
if region is not None and normalized_region is None:
raise OpenAIError("The Bedrock AWS `region` must not be empty.")
_validate_bedrock_region(normalized_region)
region_source: Literal["explicit", "environment"] | None = "explicit" if normalized_region is not None else None
configured_base_url: httpx2.URL | None
if isinstance(base_url, NotGiven):
environment_base_url = _normalize_optional_string(os.environ.get("AWS_BEDROCK_BASE_URL"))
configured_base_url = _normalize_base_url(environment_base_url) if environment_base_url else None
elif base_url is None:
configured_base_url = None
else:
if isinstance(base_url, str) and not base_url.strip():
raise OpenAIError("The Bedrock `base_url` must not be empty.")
configured_base_url = _normalize_base_url(base_url)View on GitHub (pinned to 9917c6e28e)
Solutions
- Set endpoint to exactly 'mantle' or 'runtime', or omit it to let the provider infer from base_url
- Pass full hostnames via base_url instead of endpoint
Example fix
// before bedrock(endpoint='bedrock-runtime') // after bedrock(endpoint='runtime')
Defensive patterns
Strategy: validation
Validate before calling
if endpoint is not None and endpoint not in {'mantle', 'runtime'}:
raise ValueError('endpoint must be mantle or runtime') Type guard
from typing import Literal
def is_bedrock_endpoint(v: object) -> bool:
return v in ('mantle', 'runtime') Try / catch
try:
bedrock(endpoint=endpoint)
except OpenAIError as e:
if 'endpoint' in str(e):
# fall back to auto-detection
bedrock() Prevention
- Keep endpoint as a Literal['mantle','runtime'] typed variable
- Use base_url for custom hosts, never endpoint
When it happens
Trigger: Calling `openai.providers.bedrock(endpoint='bedrock-runtime', ...)` or passing a hostname/URL such as 'https://bedrock-runtime.us-east-1.amazonaws.com' as endpoint; also typos or wrong casing like 'Runtime'.
Common situations: Developers confuse the logical endpoint name with the AWS service hostname, or copy endpoint values from AWS docs instead of the SDK's `mantle`/`runtime` enum.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- The `api_key` argument must not be empty.
- Configure `provider` on `OpenAI`, not on `BedrockOpenAI.with
- Configure `provider` on `AsyncOpenAI`, not on `AsyncBedrockO
- The Bedrock {canonical_family} hostname does not match the s
- The Bedrock bearer credential provider must return a non-emp
AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28).
Data as JSON: /api/errors/600017e43ebe5f8f.
Report an issue: GitHub.