Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(vcr): match real Bedrock hostnames in live-call probe

Cursor Agentdd89b9304f4b
diff --git a/tests/_vcr_conftest_common.py b/tests/_vcr_conftest_common.py
index 2bdddb69d0f..0b9b0bcd75a 100644
--- a/tests/_vcr_conftest_common.py
+++ b/tests/_vcr_conftest_common.py
@@ -514,7 +514,6 @@ _LIVE_CALL_HOST_SUFFIXES = (
".vertexai.googleapis.com",
".aiplatform.googleapis.com",
".googleapis.com",
- ".bedrock-runtime.amazonaws.com",
".x.ai",
".cohere.ai",
".cohere.com",
@@ -758,7 +757,6 @@ def _format_verdict_line(verdict: str, cassette, extra: str = "") -> str:
# "confirmed: this test connected to host X".
# ---------------------------------------------------------------------------
-_LIVE_CALL_PROBE_INSTALLED = False
_LIVE_CALL_BUFFER_KEY = "vcr_live_call_hosts"
@@ -768,7 +766,16 @@ def _is_live_call_host(host: str) -> bool:
host = host.lower()
if any(host.startswith(p) for p in _LIVE_CALL_LOCAL_PREFIXES):
return False
- return any(host.endswith(suffix) for suffix in _LIVE_CALL_HOST_SUFFIXES)
+ if any(host.endswith(suffix) for suffix in _LIVE_CALL_HOST_SUFFIXES):
+ return True
+ # AWS Bedrock endpoints are ``bedrock-runtime[-fips].{region}.amazonaws.com``
+ # (region between ``bedrock-runtime`` and ``amazonaws.com``), so plain
+ # suffix matching can't catch them.
+ if host.endswith(".amazonaws.com") and host.split(".", 1)[0].startswith(
+ "bedrock-runtime"
+ ):
+ return True
+ return False
class _LiveCallProbe:
diff --git a/tests/llm_translation/test_vcr_classification.py b/tests/llm_translation/test_vcr_classification.py
index a73a44dff19..3b08ef5d37a 100644
--- a/tests/llm_translation/test_vcr_classification.py
+++ b/tests/llm_translation/test_vcr_classification.py
@@ -178,8 +178,9 @@ def test_should_distinguish_different_aws_access_keys():
[
("api.openai.com", True),
("api.anthropic.com", True),
- ("bedrock-runtime.us-east-1.amazonaws.com", False),
- ("api.us-east-1.bedrock-runtime.amazonaws.com", True),
+ ("bedrock-runtime.us-east-1.amazonaws.com", True),
+ ("bedrock-runtime-fips.us-east-1.amazonaws.com", True),
+ ("api.us-east-1.bedrock-runtime.amazonaws.com", False),
("foo.bar.openai.com", True),
("127.0.0.1", False),
("localhost", False),