Skip to content

Conversation

@OlivverX
Copy link

Fix: Handle global location for Vertex AI Gemini image generation

Description

This PR fixes a bug in the Vertex AI Gemini image generation implementation that caused DNS resolution errors when using vertex_location="global".

Problem

When calling Vertex AI Gemini image generation models (e.g., gemini-3-pro-image-preview) with vertex_location="global", the code constructs an invalid URL:

https://global-aiplatform.googleapis.com

This URL does not exist and causes a DNS resolution error.

Root Cause

The current implementation in vertex_gemini_transformation.py always prefixes the location to the domain:

base_url = f"https://{vertex_location}-aiplatform.googleapis.com"

However, the global endpoint should not have a region prefix.

Solution

Added a conditional check to handle the global location correctly:

if vertex_location == "global":
    base_url = "https://aiplatform.googleapis.com"
else:
    base_url = f"https://{vertex_location}-aiplatform.googleapis.com"

Testing

Tested with gemini-3-pro-image-preview model using both global and regional locations:

  • vertex_location="global" - now works correctly
  • vertex_location="us-central1" - continues to work as before

Files Changed

  • litellm/llms/vertex_ai/image_generation/vertex_gemini_transformation.py

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Impact

This fix enables users to use Vertex AI Gemini image generation models with the global endpoint, expanding deployment flexibility.

- Add check for 'global' location to use correct API endpoint
- Global location uses aiplatform.googleapis.com without region prefix
- Regional locations use {region}-aiplatform.googleapis.com format
- Fixes URL construction error when using vertex_location='global'

Resolves issue with gemini-3-pro-image-preview model on global endpoint
@vercel
Copy link

vercel bot commented Nov 28, 2025

@OlivverX is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Nov 28, 2025

CLA assistant check
All committers have signed the CLA.

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.

2 participants