Skip to content

Commit d0aa2b8

Browse files
TomerAberbachstainless-app[bot]
authored andcommitted
feat(vertex): add support for US multi-region endpoint
1 parent 66e738d commit d0aa2b8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/anthropic/lib/vertex/_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def __init__(
119119
if base_url is None:
120120
if region == "global":
121121
base_url = "https://aiplatform.googleapis.com/v1"
122+
elif region == "us":
123+
base_url = "https://aiplatform.us.rep.googleapis.com/v1"
122124
else:
123125
base_url = f"https://{region}-aiplatform.googleapis.com/v1"
124126

tests/lib/test_vertex.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ def test_global_region_base_url(self) -> None:
124124
client = AnthropicVertex(region="global", project_id="test-project", access_token="fake-token")
125125
assert str(client.base_url).rstrip("/") == "https://aiplatform.googleapis.com/v1"
126126

127+
def test_us_region_base_url(self) -> None:
128+
"""Test that us region uses the correct base URL."""
129+
client = AnthropicVertex(region="us", project_id="test-project", access_token="fake-token")
130+
assert str(client.base_url).rstrip("/") == "https://aiplatform.us.rep.googleapis.com/v1"
131+
127132
@pytest.mark.parametrize("region", ["us-central1", "europe-west1", "asia-southeast1"])
128133
def test_regional_base_url(self, region: str) -> None:
129134
"""Test that regional endpoints use the correct base URL format."""

0 commit comments

Comments
 (0)