From cc780ecf5a0c27b7e92ec849f77ab26b0586bdd9 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 28 May 2025 11:33:39 -0700 Subject: [PATCH] fix(vertex_llm_base.py): handle default vertex location --- litellm/llms/vertex_ai/vertex_llm_base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/litellm/llms/vertex_ai/vertex_llm_base.py b/litellm/llms/vertex_ai/vertex_llm_base.py index 4d0dd8a75b8..6d118cc658a 100644 --- a/litellm/llms/vertex_ai/vertex_llm_base.py +++ b/litellm/llms/vertex_ai/vertex_llm_base.py @@ -135,15 +135,20 @@ class VertexBase: return google_auth.default(scopes=scopes) + def get_default_vertex_location(self) -> str: + return "us-central1" + def get_api_base( self, api_base: Optional[str], vertex_location: Optional[str] ) -> str: if api_base: return api_base - elif vertex_location and vertex_location == "global": + elif vertex_location == "global": return "https://aiplatform.googleapis.com" - else: + elif vertex_location: return f"https://{vertex_location}-aiplatform.googleapis.com" + else: + return f"https://{self.get_default_vertex_location()}-aiplatform.googleapis.com" def refresh_auth(self, credentials: Any) -> None: from google.auth.transport.requests import (