diff --git a/litellm/main.py b/litellm/main.py index 89750ef46b..ae5d675c63 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -1417,9 +1417,15 @@ def completion( return response response = model_response elif custom_llm_provider == "vertex_ai": - vertex_ai_project = litellm.vertex_project or get_secret("VERTEXAI_PROJECT") - vertex_ai_location = litellm.vertex_location or get_secret( - "VERTEXAI_LOCATION" + vertex_ai_project = ( + optional_params.pop("vertex_ai_project", None) + or litellm.vertex_project + or get_secret("VERTEXAI_PROJECT") + ) + vertex_ai_location = ( + optional_params.pop("vertex_ai_location", None) + or litellm.vertex_location + or get_secret("VERTEXAI_LOCATION") ) model_response = vertex_ai.completion( diff --git a/litellm/tests/test_amazing_vertex_completion.py b/litellm/tests/test_amazing_vertex_completion.py index 8467e44341..85c1cb9337 100644 --- a/litellm/tests/test_amazing_vertex_completion.py +++ b/litellm/tests/test_amazing_vertex_completion.py @@ -95,7 +95,8 @@ def test_vertex_ai(): + litellm.vertex_code_text_models ) litellm.set_verbose = False - litellm.vertex_project = "reliablekeys" + vertex_ai_project = "reliablekeys" + # litellm.vertex_project = "reliablekeys" test_models = random.sample(test_models, 1) # test_models += litellm.vertex_language_models # always test gemini-pro @@ -117,6 +118,7 @@ def test_vertex_ai(): model=model, messages=[{"role": "user", "content": "hi"}], temperature=0.7, + vertex_ai_project=vertex_ai_project, ) print("\nModel Response", response) print(response) diff --git a/litellm/utils.py b/litellm/utils.py index 2bc1d34e9e..63fab74ccb 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -3351,6 +3351,10 @@ def get_optional_params( custom_llm_provider != "bedrock" and custom_llm_provider != "sagemaker" ): # allow dynamically setting boto3 init logic continue + elif ( + k.startswith("vertex_") and custom_llm_provider != "vertex_ai" + ): # allow dynamically setting vertex ai init logic + continue passed_params[k] = v default_params = { "functions": None,