Skip to content

@ai-sdk/google-vertex: Broken URL generated when using location: 'global' (Required for gemini-3.1-pro-preview) #14702

Closed

Description

@steve-in-tandem

Description

When trying to use the new gemini-3.1-pro-preview model on Vertex AI, Google requires the location to be set to global. However, the SDK constructs an invalid base URL when location is set to 'global'.

The Bug: At packages/provider-utils/src/google-vertex-provider.ts (around line 272), the SDK constructs the URL like this:

typescript
https://${region}-aiplatform.googleapis.com/v1/projects/${project}/locations/${region}/publishers/google
When location: 'global' is passed, it generates: ❌ https://global-aiplatform.googleapis.com/v1/... (This host does not exist and returns ENOTFOUND).

The correct Vertex AI global endpoint does not have a region prefix: ✅ https://aiplatform.googleapis.com/v1/...

Steps to Reproduce
import { createVertex } from '@ai-sdk/google-vertex';

const vertex = createVertex({
project: 'my-project',
location: 'global', // Required for 3.1 Pro
});

const model = vertex('gemini-3.1-pro-preview');
// Throws: fetch failed -> getaddrinfo ENOTFOUND global-aiplatform.googleapis.com

Workaround
Manually overriding the baseURL bypasses the bug and successfully connects to the model:

const vertex = createVertex({
project: 'my-project',
location: 'global',
baseURL: https://aiplatform.googleapis.com/v1/projects/my-project/locations/global/publishers/google,
});

Expected Behavior
If location === 'global', the SDK should omit the ${region}- prefix from the subdomain and use aiplatform.googleapis.com.

AI SDK Version

@ai-sdk/[email protected]

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. aayush-kapoor commented on Apr 27, 2026

    @aayush-kapoor
    Collaborator

    @SmileFlow-Steve the version you're using is outdated by a couple of major versions. the fix is already present in the latest stable version of the package!

    const baseHost = `${region === 'global' ? '' : region + '-'}aiplatform.googleapis.com`;

    i'd recommend installing the latest package version

    pnpm add @ai-sdk/google-vertex@latest
    
  2. lgrammel commented on Jul 22, 2026

    @lgrammel
    Collaborator

    Identify issue type

    Identified as None
    Confidence: High

    Rationale

    Although the original report describes a concrete failure in an old version, the maintainer confirms it is already fixed in the current stable package. The remaining issue is an upgrade/support matter rather than an active bug or requested change.

    Evidence

    • The reported failure occurs in @ai-sdk/[email protected], where location: 'global' generates the nonexistent host global-aiplatform.googleapis.com.
    • A maintainer states that this package version is several major versions outdated and that global endpoint handling is already fixed in the latest stable release.
    • The recommended resolution is upgrading to @ai-sdk/google-vertex@latest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions