Repository navigation
fix(vertex): move the region-derived base_url when copy() changes the region - #2043
Open
johnkaram02 wants to merge 1 commit into
Open
johnkaram02 wants to merge 1 commit into
johnkaram02 wants to merge 1 commit into
Conversation
… region AnthropicVertex.copy() and with_options() accept a new region but kept the base URL of the original region. A client created with region="us-east5" and copied with region="europe-west1" sent requests to https://us-east5-aiplatform.googleapis.com with a locations/europe-west1 path. When the current base URL is the one derived from the current region, derive a new one from the new region. A custom base URL, from the argument or from ANTHROPIC_VERTEX_BASE_URL, is kept. AnthropicAWS already handles a region change in copy() the same way.
chrikrah
approved these changes
Oct 29, 2026
chrikrah
left a comment
There was a problem hiding this comment.
@johnkaram02 from my side this is ready to merge. It is the same guard AnthropicAWS.copy() got in f21982a, and pulling region_base_url() out also stops the sync and async branches drifting apart again, which is what 162fb21 had to fix.
# git archive 346e94ef, uv sync --all-extras --group dev, Python 3.10.21; anthropic resolves into each tree
$ python -m pytest tests/lib/test_vertex.py -q -p no:cacheprovider
43 passed # head 346e94ef
4 failed, 39 passed # vertex/_client.py from base 202db72
# not run: a live Vertex call
non-blocking: AnthropicBedrock.copy(aws_region=...) keeps the old host too. At this head, AnthropicBedrock(aws_region="us-east-1", ...).copy(aws_region="eu-west-1").base_url is still https://bedrock-runtime.us-east-1.amazonaws.com, so SigV4 signs for eu-west-1 against a us-east-1 host.
I'd leave this PR to Vertex and give Bedrock its own change with its own tests. Do you plan to take that one?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
AnthropicVertex.copy()andwith_options()accept a newregion, but they kept the original region'sbase_url. The request path is built from the new region, so the request went to the wrong host.