diff --git a/litellm/llms/watsonx/common_utils.py b/litellm/llms/watsonx/common_utils.py index d6f296c6081..c756be6d458 100644 --- a/litellm/llms/watsonx/common_utils.py +++ b/litellm/llms/watsonx/common_utils.py @@ -38,7 +38,11 @@ def generate_iam_token(api_key=None, **params) -> str: headers = {} headers["Content-Type"] = "application/x-www-form-urlencoded" if api_key is None: - api_key = get_secret_str("WX_API_KEY") or get_secret_str("WATSONX_API_KEY") or get_secret_str("WATSONX_APIKEY") + api_key = ( + get_secret_str("WX_API_KEY") + or get_secret_str("WATSONX_API_KEY") + or get_secret_str("WATSONX_APIKEY") + ) if api_key is None: raise ValueError("API key is required") headers["Accept"] = "application/json" @@ -280,13 +284,9 @@ class IBMWatsonXMixin: def _prepare_payload(self, model: str, api_params: WatsonXAPIParams) -> dict: payload: dict = {} if model.startswith("deployment/"): - if api_params["space_id"] is None: - raise WatsonXAIError( - status_code=401, - message="Error: space_id is required for models called using the 'deployment/' endpoint. Pass in the space_id as a parameter or set it in the WX_SPACE_ID environment variable.", - ) - payload["space_id"] = api_params["space_id"] - return payload + return ( + {} + ) # Deployment models do not support 'space_id' or 'project_id' in their payload payload["model_id"] = model payload["project_id"] = api_params["project_id"] return payload diff --git a/litellm/proxy/pass_through_endpoints/passthrough_endpoint_router.py b/litellm/proxy/pass_through_endpoints/passthrough_endpoint_router.py index a02cacc3cc0..9335ce49bb7 100644 --- a/litellm/proxy/pass_through_endpoints/passthrough_endpoint_router.py +++ b/litellm/proxy/pass_through_endpoints/passthrough_endpoint_router.py @@ -110,7 +110,7 @@ class PassthroughEndpointRouter: self, project_id: str, location: str, - vertex_credentials: VERTEX_CREDENTIALS_TYPES, + vertex_credentials: Optional[VERTEX_CREDENTIALS_TYPES], ): """ Add the vertex credentials for the given project-id, location diff --git a/litellm/router.py b/litellm/router.py index ae45212dccf..e8cba56b249 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -4740,13 +4740,9 @@ class Router: or deployment.litellm_params.vertex_credentials ) - if ( - vertex_project is None - or vertex_location is None - or vertex_credentials is None - ): + if vertex_project is None or vertex_location is None: raise ValueError( - "vertex_project, vertex_location, and vertex_credentials must be set in litellm_params for pass-through endpoints" + "vertex_project, and vertex_location must be set in litellm_params for pass-through endpoints." ) passthrough_endpoint_router.add_vertex_credentials( project_id=vertex_project, diff --git a/tests/llm_translation/test_watsonx.py b/tests/llm_translation/test_watsonx.py index d788541dada..e0c125a9017 100644 --- a/tests/llm_translation/test_watsonx.py +++ b/tests/llm_translation/test_watsonx.py @@ -206,7 +206,7 @@ def test_watsonx_deployment_space_id(monkeypatch, watsonx_chat_completion_call, assert mock_post.call_count == 1 json_data = json.loads(mock_post.call_args.kwargs["data"]) - assert my_fake_space_id == json_data["space_id"] + assert my_fake_space_id not in json_data def test_watsonx_deployment_space_id_embedding(monkeypatch, watsonx_embedding_call): @@ -217,4 +217,4 @@ def test_watsonx_deployment_space_id_embedding(monkeypatch, watsonx_embedding_ca assert mock_post.call_count == 1 json_data = json.loads(mock_post.call_args.kwargs["data"]) - assert my_fake_space_id == json_data["space_id"] + assert my_fake_space_id not in json_data diff --git a/tests/router_unit_tests/test_router_adding_deployments.py b/tests/router_unit_tests/test_router_adding_deployments.py index 55481394bb1..6e2a7b79733 100644 --- a/tests/router_unit_tests/test_router_adding_deployments.py +++ b/tests/router_unit_tests/test_router_adding_deployments.py @@ -92,7 +92,7 @@ def test_initialize_deployment_for_pass_through_missing_params(): # Test that initialization raises ValueError with pytest.raises( ValueError, - match="vertex_project, vertex_location, and vertex_credentials must be set", + match="vertex_project, and vertex_location must be set in litellm_params for pass-through endpoints", ): router._initialize_deployment_for_pass_through( deployment=deployment,