{"record":{"id":"89155542456f16aa","repo":"openai/openai-python","slug":"the-bedrock-canonical-family-hostname-does-not-m","errorCode":null,"errorMessage":"The Bedrock {canonical_family} hostname does not match the selected `{endpoint}` endpoint. Set `endpoint='{canonical_family}'` to use this hostname.","messagePattern":"The Bedrock (.+?) hostname does not match the selected `(.+?)` endpoint\\. Set `endpoint='(.+?)'` to use this hostname\\.","errorType":"error_code","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"src/openai/providers/bedrock.py","lineNumber":93,"sourceCode":"\n\ndef _validate_bedrock_region(region: str | None) -> None:\n    if region is not None and _AWS_REGION.fullmatch(region) is None:\n        raise OpenAIError(\"The Bedrock AWS `region` is invalid. Use a standard AWS region such as `us-east-1`.\")\n\n\ndef _validate_canonical_bedrock_endpoint(\n    base_url: httpx2.URL, *, endpoint: BedrockEndpoint, region: str | None\n) -> None:\n    canonical_endpoint = _parse_bedrock_endpoint_hostname(base_url.host)\n    if canonical_endpoint is None:\n        return\n\n    canonical_family, canonical_region = canonical_endpoint\n    if base_url.scheme != \"https\":\n        raise OpenAIError(\"Canonical Amazon Bedrock endpoints require HTTPS.\")\n    if canonical_family != endpoint:\n        raise OpenAIError(\n            f\"The Bedrock {canonical_family} hostname does not match the selected `{endpoint}` endpoint. \"\n            f\"Set `endpoint='{canonical_family}'` to use this hostname.\"\n        )\n    if region is not None and canonical_region != region:\n        raise OpenAIError(\n            f\"The Bedrock endpoint region `{canonical_region}` does not match the configured AWS region `{region}`.\"\n        )\n\n\ndef _default_bedrock_base_url(endpoint: BedrockEndpoint, region: str) -> httpx2.URL:\n    hostname = (\n        f\"bedrock-runtime.{region}.{_runtime_dns_suffixes(region)[0]}\"\n        if endpoint == \"runtime\"\n        else f\"bedrock-mantle.{region}.api.aws\"\n    )\n    return _normalize_base_url(f\"https://{hostname}/openai/v1\")\n\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/providers/bedrock.py#L75-L111","documentation":"The hostname family parsed from base_url (e.g. `bedrock-runtime`, `bedrock`, `bedrock-agent-runtime`) differs from the `endpoint` value you selected in bedrock(...). Bedrock's different services have distinct hostnames, and mixing them would send signed requests to the wrong service, so the provider refuses.","triggerScenarios":"Selecting `endpoint=\"runtime\"` (default) but passing base_url `https://bedrock.us-east-1.amazonaws.com` (control-plane FIPS or other family), or endpoint=\"bedrock\" with a bedrock-runtime hostname, etc.","commonSituations":"Copying a base_url for a different Bedrock service from AWS docs; enabling FIPS or a preview endpoint without updating the endpoint parameter.","solutions":["Set endpoint to the family shown in the message, e.g. `bedrock(endpoint='bedrock')`.","Or change base_url to the hostname matching your selected endpoint."],"exampleFix":"// before\nprovider = bedrock(base_url=\"https://bedrock.us-east-1.amazonaws.com\")\n\n// after\nprovider = bedrock(endpoint=\"bedrock\", base_url=\"https://bedrock.us-east-1.amazonaws.com\")","handlingStrategy":"validation","validationCode":"from httpx2 import URL\nimport re\nm = re.match(r\"^(bedrock[a-z-]*)\\.[a-z0-9-]+\\.amazonaws\\.com$\", URL(base_url).host or \"\")\nif m and m.group(1) != endpoint:\n    endpoint = m.group(1)  # align endpoint with hostname","typeGuard":"def endpoint_matches_host(endpoint: str, base_url: str) -> bool:\n    import re\n    host = URL(base_url).host or \"\"\n    m = re.match(r\"^(bedrock[a-z-]*)\\.\", host)\n    return m is None or m.group(1) == endpoint","tryCatchPattern":"try:\n    provider = bedrock(endpoint=endpoint, base_url=base_url)\nexcept OpenAIError as e:\n    if \"does not match\" in str(e):\n        import re\n        fam = re.search(r\"Set `endpoint='([a-z-]+)'`\", str(e))\n        provider = bedrock(endpoint=fam.group(1), base_url=base_url)\n    else:\n        raise","preventionTips":["Derive the endpoint parameter from the hostname family when configuring custom base_urls.","Prefer omitting base_url so the provider derives it from endpoint+region.","Document which Bedrock service family each base_url targets."],"tags":["bedrock","aws","endpoint","config"],"backgroundTag":"endpoint-mismatch","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}