Skip to content

fix(vertex): async client missing us/eu multi-region base_url branches#1406

Open
atob1 wants to merge 1 commit intoanthropics:mainfrom
atob1:fix/async-vertex-us-eu-multi-region
Open

fix(vertex): async client missing us/eu multi-region base_url branches#1406
atob1 wants to merge 1 commit intoanthropics:mainfrom
atob1:fix/async-vertex-us-eu-multi-region

Conversation

@atob1
Copy link
Copy Markdown

@atob1 atob1 commented Apr 17, 2026

Summary

AnthropicVertex.__init__ (sync) 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). Those branches were never added to AsyncAnthropicVertex.__init__, so passing region="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 elif branches from the sync class into the async class. 4 lines added, no other changes.

Repro (SDK 0.96.0, before fix)

import anthropic, asyncio

async def main():
    c = anthropic.AsyncAnthropicVertex(project_id="YOUR_PROJECT", region="us")
    print(c.base_url)
    # https://us-aiplatform.googleapis.com/v1/   <-- wrong hostname
    await c.messages.create(
        model="claude-opus-4-7",
        max_tokens=16,
        messages=[{"role": "user", "content": "hi"}],
    )
    # anthropic.NotFoundError: Error code: 404 (HTML page from GCP URL router)

asyncio.run(main())

After fix

c.base_url becomes https://aiplatform.us.rep.googleapis.com/v1/ — matches the sync client and the working US multi-region endpoint, and the request succeeds.

Test plan

  • Unit: add a test that AsyncAnthropicVertex(region="us").base_url ends with aiplatform.us.rep.googleapis.com/v1/ (mirror whatever the sync test does)
  • Manual: verified messages.create now returns 200 against region="us" with claude-opus-4-7

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.
@atob1 atob1 requested a review from a team as a code owner April 17, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant