fix: Handle global location for Vertex AI image generation endpoint #17255
+5
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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) withvertex_location="global", the code constructs an invalid URL:This URL does not exist and causes a DNS resolution error.
Root Cause
The current implementation in
vertex_gemini_transformation.pyalways prefixes the location to the domain:However, the global endpoint should not have a region prefix.
Solution
Added a conditional check to handle the global location correctly:
Testing
Tested with
gemini-3-pro-image-previewmodel using both global and regional locations:vertex_location="global"- now works correctlyvertex_location="us-central1"- continues to work as beforeFiles Changed
litellm/llms/vertex_ai/image_generation/vertex_gemini_transformation.pyType of Change
Impact
This fix enables users to use Vertex AI Gemini image generation models with the global endpoint, expanding deployment flexibility.