From 6d282282457870920d57642efde40e49964babb2 Mon Sep 17 00:00:00 2001 From: Chesars Date: Fri, 30 Jan 2026 14:39:13 -0300 Subject: [PATCH] refactor(vertex_ai): reuse get_vertex_base_url for URL construction Use existing get_vertex_base_url from common_utils instead of duplicating the global vs regional URL logic in create_vertex_url and get_api_base. --- litellm/llms/vertex_ai/vertex_llm_base.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/litellm/llms/vertex_ai/vertex_llm_base.py b/litellm/llms/vertex_ai/vertex_llm_base.py index 1310e66e1db..4613b6a5715 100644 --- a/litellm/llms/vertex_ai/vertex_llm_base.py +++ b/litellm/llms/vertex_ai/vertex_llm_base.py @@ -20,6 +20,7 @@ from .common_utils import ( _get_vertex_url, all_gemini_url_modes, get_vertex_base_model_name, + get_vertex_base_url, is_global_only_vertex_model, ) @@ -200,12 +201,7 @@ class VertexBase: ) -> str: if api_base: return api_base - elif vertex_location == "global": - return "https://aiplatform.googleapis.com" - elif vertex_location: - return f"https://{vertex_location}-aiplatform.googleapis.com" - else: - return f"https://{self.get_default_vertex_location()}-aiplatform.googleapis.com" + return get_vertex_base_url(vertex_location or self.get_default_vertex_location()) @staticmethod def create_vertex_url( @@ -218,12 +214,8 @@ class VertexBase: ) -> str: """Return the base url for the vertex partner models""" - # For global location, use the non-regional URL if api_base is None: - if vertex_location == "global": - api_base = "https://aiplatform.googleapis.com" - else: - api_base = f"https://{vertex_location}-aiplatform.googleapis.com" + api_base = get_vertex_base_url(vertex_location) if partner == VertexPartnerProvider.llama: return f"{api_base}/v1/projects/{vertex_project}/locations/{vertex_location}/endpoints/openapi/chat/completions" elif partner == VertexPartnerProvider.mistralai: