The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Fix:add async_get_available_deployment_for_pass_through in code tests
Sameer Kankute09fb1581cbd4
diff --git a/tests/local_testing/test_router_get_deployments.py b/tests/local_testing/test_router_get_deployments.pyindex 358ed74f55c..8df04b4f1d3 100644--- a/tests/local_testing/test_router_get_deployments.py+++ b/tests/local_testing/test_router_get_deployments.py@@ -592,3 +592,205 @@ async def test_weighted_selection_router_async(rpm_list, tpm_list):except Exception as e:traceback.print_exc()pytest.fail(f"Error occurred: {e}")+++def test_get_available_deployment_for_pass_through():+ """+ Test get_available_deployment_for_pass_through function+ - Tests that only deployments with use_in_pass_through=True are returned+ - Tests that BadRequestError is raised when no pass-through deployments exist+ """+ try:+ litellm.set_verbose = False+ model_list = [+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {+ "model": "gpt-3.5-turbo",+ "api_key": os.getenv("OPENAI_API_KEY"),+ "use_in_pass_through": True,+ },+ },+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {+ "model": "azure/gpt-4.1-mini",+ "api_key": os.getenv("AZURE_API_KEY"),+ "api_base": os.getenv("AZURE_API_BASE"),+ "api_version": os.getenv("AZURE_API_VERSION"),+ "use_in_pass_through": False,+ },+ },+ ]+ router = Router(+ model_list=model_list,+ )++ # Test that only pass-through deployment is returned+ selected_model = router.get_available_deployment_for_pass_through(+ "gpt-3.5-turbo"+ )+ assert selected_model["litellm_params"]["model"] == "gpt-3.5-turbo"+ assert selected_model["litellm_params"]["use_in_pass_through"] is True++ router.reset()+ except Exception as e:+ traceback.print_exc()+ pytest.fail(f"Error occurred: {e}")+++def test_get_available_deployment_for_pass_through_no_deployments():+ """+ Test get_available_deployment_for_pass_through raises BadRequestError+ when no deployments have use_in_pass_through=True+ """+ try:+ litellm.set_verbose = False+ model_list = [+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {+ "model": "gpt-3.5-turbo",+ "api_key": os.getenv("OPENAI_API_KEY"),+ "use_in_pass_through": False,+ },+ },+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {+ "model": "azure/gpt-4.1-mini",+ "api_key": os.getenv("AZURE_API_KEY"),+ "api_base": os.getenv("AZURE_API_BASE"),+ "api_version": os.getenv("AZURE_API_VERSION"),+ "use_in_pass_through": False,+ },+ },+ ]+ router = Router(+ model_list=model_list,+ )++ # Test that BadRequestError is raised when no pass-through deployments exist+ try:+ router.get_available_deployment_for_pass_through("gpt-3.5-turbo")+ pytest.fail(+ "Expected BadRequestError when no pass-through deployments exist"+ )+ except litellm.BadRequestError as e:+ assert "use_in_pass_through=True" in str(e)++ router.reset()+ except Exception as e:+ if isinstance(e, litellm.BadRequestError):+ pass # Expected error+ else:+ traceback.print_exc()+ pytest.fail(f"Error occurred: {e}")+++async def test_async_get_available_deployment_for_pass_through():+ """+ Test async_get_available_deployment_for_pass_through function+ - Tests that only deployments with use_in_pass_through=True are returned+ - Tests async version works correctly+ """+ try:+ litellm.set_verbose = False+ model_list = [+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {+ "model": "gpt-3.5-turbo",+ "api_key": os.getenv("OPENAI_API_KEY"),+ "use_in_pass_through": True,+ },+ },+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {+ "model": "azure/gpt-4.1-mini",+ "api_key": os.getenv("AZURE_API_KEY"),+ "api_base": os.getenv("AZURE_API_BASE"),+ "api_version": os.getenv("AZURE_API_VERSION"),+ "use_in_pass_through": False,+ },+ },+ ]+ router = Router(+ model_list=model_list,+ )++ # Test that only pass-through deployment is returned+ selected_model = await router.async_get_available_deployment_for_pass_through(+ model="gpt-3.5-turbo", request_kwargs={}+ )+ assert selected_model["litellm_params"]["model"] == "gpt-3.5-turbo"+ assert selected_model["litellm_params"]["use_in_pass_through"] is True++ router.reset()+ except Exception as e:+ traceback.print_exc()+ pytest.fail(f"Error occurred: {e}")+++def test_filter_pass_through_deployments():+ """+ Test _filter_pass_through_deployments function+ - Tests that it correctly filters deployments with use_in_pass_through=True+ """+ try:+ litellm.set_verbose = False+ model_list = [+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {+ "model": "gpt-3.5-turbo",+ "api_key": os.getenv("OPENAI_API_KEY"),+ "use_in_pass_through": True,+ },+ },+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {+ "model": "azure/gpt-4.1-mini",+ "api_key": os.getenv("AZURE_API_KEY"),+ "api_base": os.getenv("AZURE_API_BASE"),+ "api_version": os.getenv("AZURE_API_VERSION"),+ "use_in_pass_through": False,+ },+ },+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {+ "model": "azure/gpt-35-turbo",+ "api_key": os.getenv("AZURE_API_KEY"),+ "api_base": os.getenv("AZURE_API_BASE"),+ "api_version": os.getenv("AZURE_API_VERSION"),+ "use_in_pass_through": True,+ },+ },+ ]+ router = Router(+ model_list=model_list,+ )++ # Get all healthy deployments+ healthy_deployments = router.get_model_list()++ # Filter pass-through deployments+ pass_through_deployments = router._filter_pass_through_deployments(+ healthy_deployments+ )++ # Should only have 2 deployments with use_in_pass_through=True+ assert len(pass_through_deployments) == 2++ # Verify all returned deployments have use_in_pass_through=True+ for deployment in pass_through_deployments:+ assert deployment["litellm_params"]["use_in_pass_through"] is True++ router.reset()+ except Exception as e:+ traceback.print_exc()+ pytest.fail(f"Error occurred: {e}")