diff --git a/tests/router_unit_tests/test_router_helper_utils.py b/tests/router_unit_tests/test_router_helper_utils.py index 673c606a7d..99926b39c9 100644 --- a/tests/router_unit_tests/test_router_helper_utils.py +++ b/tests/router_unit_tests/test_router_helper_utils.py @@ -2198,3 +2198,33 @@ def test_get_valid_args(): # Verify it contains keyword-only arguments too # These are common Router.__init__ parameters assert "assistants_config" in valid_args or "search_tools" in valid_args + + +def test_get_router_model_info_with_deployment_object(): + """Test get_router_model_info accepts Deployment object directly and reuses LiteLLM_Params""" + router = Router( + model_list=[ + { + "model_name": "gpt-4", + "litellm_params": {"model": "gpt-4", "api_key": "test-key"}, + "model_info": {"id": "test-id"}, + } + ] + ) + + # Get the Deployment object (not dict) + deployment = router.get_deployment(model_id="test-id") + assert deployment is not None + assert isinstance(deployment, Deployment) + assert isinstance(deployment.litellm_params, LiteLLM_Params) + + # Pass Deployment directly (not .model_dump()) - this exercises the isinstance check + # that reuses the existing LiteLLM_Params instead of reconstructing it + model_info = router.get_router_model_info( + deployment=deployment, + received_model_name="gpt-4", + ) + + # Verify we got valid model info back + assert model_info is not None + assert isinstance(model_info, dict)