Description
Summary
The @ai-sdk/google-vertex Gemini provider (google-vertex-provider-base.ts) builds an incorrect hostname when location is set to 'us' or 'eu', producing a 404 Not Found for every request.
This is the same root-cause bug as #14634 (Anthropic provider on Vertex), which is already fixed in PR #14744. The fix has not been applied to the Gemini provider.
Problem
When location: 'us' or location: 'eu' is passed, the SDK builds the base URL as:
This host does not exist and the request returns 404 Not Found.
Vertex AI's multi-region endpoints (us, eu) use a Representative Endpoint (REP) hostname format, which is different from both the regional and global formats:
| Location |
Current (incorrect) URL |
Correct URL |
us-central1 (regional) |
https://us-central1-aiplatform.googleapis.com/... |
✅ correct |
global |
https://aiplatform.googleapis.com/... |
✅ correct (fixed in #6810) |
us (multi-region) |
https://us-aiplatform.googleapis.com/... |
❌ 404 — should be aiplatform.us.rep.googleapis.com |
eu (multi-region) |
https://eu-aiplatform.googleapis.com/... |
❌ 404 — should be aiplatform.eu.rep.googleapis.com |
Reference: Vertex AI Locations — Multi-region endpoints
Root cause
In packages/google-vertex/src/google-vertex-provider-base.ts:
// Current code (incorrect for us/eu multi-region)
const baseHost = `${region === 'global' ? '' : region + '-'}aiplatform.googleapis.com`;
const baseURL = `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
For region = 'us', this produces us-aiplatform.googleapis.com, which is not a valid Vertex AI endpoint.
The same bug existed in google-vertex-anthropic-provider.ts and was fixed by PR #14744 using a getHost() helper. The same fix needs to be applied here.
Reproduction
Setup
mkdir vertex-repro && cd vertex-repro
npm init -y
npm install ai@6.0.193 @ai-sdk/google-vertex@4.0.140
export GOOGLE_VERTEX_PROJECT=your-project-id
export GOOGLE_VERTEX_LOCATION=us
# Authenticate via ADC: gcloud auth application-default login
repro.mjs
import { createVertex } from '@ai-sdk/google-vertex';
import { generateText } from 'ai';
const project = process.env.GOOGLE_VERTEX_PROJECT;
// ① Broken: no baseURL override → hits us-aiplatform.googleapis.com → 404
const vertexBroken = createVertex({
project,
location: 'us',
});
// ② Workaround: explicit REP baseURL
const vertexFixed = createVertex({
project,
location: 'us',
baseURL: `https://aiplatform.us.rep.googleapis.com/v1/projects/${project}/locations/us/publishers/google`,
});
async function test(label, vertex) {
console.log(`\n=== ${label} ===`);
try {
const { text } = await generateText({
model: vertex('gemini-3.5-flash'),
prompt: 'Say "hello" in one word.',
});
console.log('✅ Success:', text);
} catch (e) {
console.error('❌ Error:', e.message);
if (e.url) console.error(' URL:', e.url);
}
}
await test('① Broken (location: us, no baseURL)', vertexBroken);
await test('② Workaround (explicit REP baseURL)', vertexFixed);
Observed output
AI SDK Version
- ai: 6.0.193
- @ai-sdk/google-vertex: 4.0.140
- Also reproduced on main (HEAD ab6d664, 2026-05-29)
Code of Conduct
Description
Summary
The
@ai-sdk/google-vertexGemini provider (google-vertex-provider-base.ts) builds an incorrect hostname whenlocationis set to'us'or'eu', producing a404 Not Foundfor every request.This is the same root-cause bug as #14634 (Anthropic provider on Vertex), which is already fixed in PR #14744. The fix has not been applied to the Gemini provider.
Problem
When
location: 'us'orlocation: 'eu'is passed, the SDK builds the base URL as:This host does not exist and the request returns
404 Not Found.Vertex AI's multi-region endpoints (
us,eu) use a Representative Endpoint (REP) hostname format, which is different from both the regional and global formats:us-central1(regional)https://us-central1-aiplatform.googleapis.com/...globalhttps://aiplatform.googleapis.com/...us(multi-region)https://us-aiplatform.googleapis.com/...aiplatform.us.rep.googleapis.comeu(multi-region)https://eu-aiplatform.googleapis.com/...aiplatform.eu.rep.googleapis.comReference: Vertex AI Locations — Multi-region endpoints
Root cause
In
packages/google-vertex/src/google-vertex-provider-base.ts:For
region = 'us', this producesus-aiplatform.googleapis.com, which is not a valid Vertex AI endpoint.The same bug existed in
google-vertex-anthropic-provider.tsand was fixed by PR #14744 using agetHost()helper. The same fix needs to be applied here.Reproduction
Setup
repro.mjsObserved output
AI SDK Version
Code of Conduct