From 48dbdaa73e1470895279a0f761aa192d823a7812 Mon Sep 17 00:00:00 2001 From: Eslam karim gaber Date: Sun, 28 Jan 2024 19:55:01 +0200 Subject: [PATCH 1/2] Change quota project to the correct project being used for the call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if not set it will use the default project in the ADC to set that quota project which is usually different  https://github.com/googleapis/python-aiplatform/issues/2557#issuecomment-1709284744 --- litellm/llms/vertex_ai.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litellm/llms/vertex_ai.py b/litellm/llms/vertex_ai.py index 57cf6c2a0ec..58a1acd7219 100644 --- a/litellm/llms/vertex_ai.py +++ b/litellm/llms/vertex_ai.py @@ -237,8 +237,10 @@ def completion( GenerationConfig, ) from google.cloud.aiplatform_v1beta1.types import content as gapic_content_types - - vertexai.init(project=vertex_project, location=vertex_location) + + ## Load credentials with the correct quota project ref: https://github.com/googleapis/python-aiplatform/issues/2557#issuecomment-1709284744 + creds, _ = google.auth.default(quota_project_id=vertex_project) + vertexai.init(project=vertex_project, location=vertex_location, credentials=creds) ## Load Config config = litellm.VertexAIConfig.get_config() From 2b3965dbf53c030e65d26ce93fdcbac1e56293fc Mon Sep 17 00:00:00 2001 From: Eslam karim gaber Date: Sun, 28 Jan 2024 23:14:06 +0200 Subject: [PATCH 2/2] imports --- litellm/llms/vertex_ai.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/llms/vertex_ai.py b/litellm/llms/vertex_ai.py index 58a1acd7219..56cef9de899 100644 --- a/litellm/llms/vertex_ai.py +++ b/litellm/llms/vertex_ai.py @@ -237,7 +237,8 @@ def completion( GenerationConfig, ) from google.cloud.aiplatform_v1beta1.types import content as gapic_content_types - + import google.auth + ## Load credentials with the correct quota project ref: https://github.com/googleapis/python-aiplatform/issues/2557#issuecomment-1709284744 creds, _ = google.auth.default(quota_project_id=vertex_project) vertexai.init(project=vertex_project, location=vertex_location, credentials=creds)