fix(vertex): async client missing us/eu multi-region base_url branches#1406
Open
atob1 wants to merge 1 commit intoanthropics:mainfrom
Open
fix(vertex): async client missing us/eu multi-region base_url branches#1406atob1 wants to merge 1 commit intoanthropics:mainfrom
atob1 wants to merge 1 commit intoanthropics:mainfrom
Conversation
The sync `AnthropicVertex.__init__` maps `region="us"` to `https://aiplatform.us.rep.googleapis.com/v1` and `region="eu"` to the `.eu.rep.googleapis.com` hostname (added in 0.89.0). The matching branches were never added to `AsyncAnthropicVertex.__init__`, so `region="us"` / `region="eu"` falls through to the generic `{region}-aiplatform.googleapis.com` branch and produces `us-aiplatform.googleapis.com`, which is not a valid endpoint and returns HTTP 404 from the GCP URL router. Repro (SDK 0.96.0): import anthropic, asyncio async def main(): c = anthropic.AsyncAnthropicVertex(project_id="...", region="us") print(c.base_url) # https://us-aiplatform.googleapis.com/v1/ <-- wrong await c.messages.create( model="claude-opus-4-7", max_tokens=16, messages=[{"role": "user", "content": "hi"}], ) # NotFoundError 404 With the fix, base_url becomes `https://aiplatform.us.rep.googleapis.com/v1/` and the request succeeds, matching the sync client's behavior.
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.
Summary
AnthropicVertex.__init__(sync) mapsregion="us"tohttps://aiplatform.us.rep.googleapis.com/v1andregion="eu"to the.eu.rep.googleapis.comhostname (added in 0.89.0). Those branches were never added toAsyncAnthropicVertex.__init__, so passingregion="us"/"eu"to the async client falls through to the generic fallback and builds{region}-aiplatform.googleapis.com, which is not a valid endpoint and returns 404 from the GCP URL router.This PR mirrors the two
elifbranches from the sync class into the async class. 4 lines added, no other changes.Repro (SDK 0.96.0, before fix)
After fix
c.base_urlbecomeshttps://aiplatform.us.rep.googleapis.com/v1/— matches the sync client and the working US multi-region endpoint, and the request succeeds.Test plan
AsyncAnthropicVertex(region="us").base_urlends withaiplatform.us.rep.googleapis.com/v1/(mirror whatever the sync test does)messages.createnow returns 200 againstregion="us"withclaude-opus-4-7