From 5efe59e6e2d31c0904dcebb99a266f246505f122 Mon Sep 17 00:00:00 2001 From: "Jugal D. Bhatt" <55304795+jugaldb@users.noreply.github.com> Date: Mon, 11 Aug 2025 15:41:08 -0700 Subject: [PATCH] [Draft] [LLM Translation] Add model id check (#13507) * Add model id check * add ruff fix --- litellm/proxy/proxy_server.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index df6f734b987..939084c38d2 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -3967,8 +3967,22 @@ async def model_info( # Validate that the requested model is accessible validate_model_access(model_id=model_id, available_models=all_models) - # Get provider information - _, provider, _, _ = litellm.get_llm_provider(model=model_id) + # Get provider information from the router deployment + if llm_router is None: + raise HTTPException( + status_code=500, + detail="Router not initialized" + ) + + deployment = llm_router.get_deployment_by_model_group_name(model_id) + if deployment is None: + raise HTTPException( + status_code=404, + detail=f"Model '{model_id}' not found in router configuration" + ) + + # Use the actual litellm model from the deployment to get provider info + _, provider, _, _ = litellm.get_llm_provider(model=deployment.litellm_params.model) # Return the model information in the same format as the list endpoint return create_model_info_response(