Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix validate_environment

Ishaan Jaffer7e0822fb555a
diff --git a/litellm/llms/vertex_ai/image_generation/vertex_imagen_transformation.py b/litellm/llms/vertex_ai/image_generation/vertex_imagen_transformation.py
index 8c4ad5dd423..4d86f7ba36d 100644
--- a/litellm/llms/vertex_ai/image_generation/vertex_imagen_transformation.py
+++ b/litellm/llms/vertex_ai/image_generation/vertex_imagen_transformation.py
@@ -122,8 +122,10 @@ class VertexAIImagenImageGenerationConfig(BaseImageGenerationConfig, VertexLLM):
"""
Get the complete URL for Vertex AI Imagen predict API
"""
- vertex_project = self._resolve_vertex_project()
- vertex_location = self._resolve_vertex_location()
+ # First check litellm_params (where vertex_ai_project/vertex_ai_location are passed)
+ # then fall back to environment variables and other sources
+ vertex_project = self.safe_get_vertex_ai_project(litellm_params) or self._resolve_vertex_project()
+ vertex_location = self.safe_get_vertex_ai_location(litellm_params) or self._resolve_vertex_location()
if not vertex_project or not vertex_location:
raise ValueError("vertex_project and vertex_location are required for Vertex AI")
@@ -151,8 +153,10 @@ class VertexAIImagenImageGenerationConfig(BaseImageGenerationConfig, VertexLLM):
api_base: Optional[str] = None,
) -> dict:
headers = headers or {}
- vertex_project = self._resolve_vertex_project()
- vertex_credentials = self._resolve_vertex_credentials()
+ # First check litellm_params (where vertex_ai_project/vertex_ai_credentials are passed)
+ # then fall back to environment variables and other sources
+ vertex_project = self.safe_get_vertex_ai_project(litellm_params) or self._resolve_vertex_project()
+ vertex_credentials = self.safe_get_vertex_ai_credentials(litellm_params) or self._resolve_vertex_credentials()
access_token, _ = self._ensure_access_token(
credentials=vertex_credentials,
project_id=vertex_project,