fix(vertex): EU/US REP + global endpoints, and fix v@ routing fall-through to OpenRouter#145
Conversation
|
Update: ran the suite locally on bun 1.3.14 — the new |
…hrough Two related Vertex fixes so EU users can run Gemini models with data residency (e.g. gemini-3.5-flash, which is published only on the EU REP endpoint). 1. Endpoint host resolution (vertex-auth.ts): the OAuth endpoint builder hardcoded <location>-aiplatform.googleapis.com, which can't address the data-residency multi-region REP hosts (aiplatform.<loc>.rep.googleapis.com for eu/us) or the global host (aiplatform.googleapis.com). Add vertexApiHost(location); per-region behavior is unchanged. 2. Provider registry (remote-provider-registry.ts): Vertex has a static baseUrl of "" (endpoint built per-region in the transport), so the empty-baseUrl filter in getRemoteProviders() dropped it. resolveRemoteProvider returned null, resolveModelProvider categorized it "unknown", and every Vertex request silently fell through to the OpenRouter default -> HTTP 401. Keep providers whose transport self-constructs the URL. Verified end-to-end: VERTEX_LOCATION=eu claudish --model v@gemini-3.5-flash reaches Vertex and returns a response. Adds unit tests for both, docs, and a .gitignore entry for the compiled binary / bun-build artifacts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
01fc4a5 to
f8c47f2
Compare
|
Expanded this PR with a second, more fundamental Vertex bug found while testing the endpoint fix end-to-end:
Fix: keep providers whose transport self-constructs the URL ( Verified end-to-end on a compiled binary (bun 1.3.14), both fixes together: That round-trips Gemini 3.5 Flash through the EU data-residency REP endpoint. Tests: 10 pass / 0 fail across |
Problem
The Vertex AI OAuth endpoint builder hardcodes a single host shape —
https://<location>-aiplatform.googleapis.com— derived fromVERTEX_LOCATION. That cannot address two endpoint families Vertex actually uses:https://aiplatform.<loc>.rep.googleapis.com(e.g.aiplatform.eu.rep.googleapis.com,location=eu).https://aiplatform.googleapis.comwithlocation=global(note: no<location>-prefix).The practical impact: Gemini models published only on those endpoints can't be used at all.
gemini-3.5-flashis currently served only on the EU REP endpoint and the global endpoint — never on the per-regioneurope-west4-aiplatform.googleapis.comhost the code builds. So EU users have no way to run 3.5 Flash with data residency.Evidence (live
:countTokensprobes against a real project)location)gemini-3.5-flashgemini-2.5-proaiplatform.eu.rep.googleapis.com/euaiplatform.googleapis.com/globalglobal-aiplatform…→ 404europe-west4-aiplatform.googleapis.com/europe-west4eu-aiplatform.googleapis.com/eu(current output forVERTEX_LOCATION=eu)So
VERTEX_LOCATION=eutoday produceseu-aiplatform.googleapis.com, which is not a valid Gemini host; the real EU multi-region host isaiplatform.eu.rep.googleapis.com.Change
Add
vertexApiHost(location)and use it inbuildVertexOAuthEndpoint(and the smoke base-URL builder):The
locations/<location>path segment is untouched in every case. Existing single-region behavior (europe-west4,us-central1, …) is byte-for-byte unchanged.Usage after this PR:
Tests / verification
packages/cli/src/auth/vertex-auth.test.tscoveringvertexApiHostandbuildVertexOAuthEndpointforeu(REP),global, and a normal region, plus the?alt=ssestreaming path.eu,global, andeurope-west4were each confirmed to return HTTP 200 from Vertex via:countTokens.bun testin my environment (bun not installed here) — please confirm CI is green.Docs
docs/settings-reference.md: documentedeu/us/globalbehavior forVERTEX_LOCATION.CHANGELOG.md:[Unreleased]entry.Refs: Vertex AI — locations/REP endpoints, data residency.
🤖 Generated with Claude Code