diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.py index 718773a1b16..dd2d733170b 100644 --- a/litellm/litellm_core_utils/get_llm_provider_logic.py +++ b/litellm/litellm_core_utils/get_llm_provider_logic.py @@ -439,6 +439,8 @@ def get_llm_provider( # noqa: PLR0915 custom_llm_provider = "amazon_nova" elif model.startswith("sap/"): custom_llm_provider = "sap" + elif model.endswith(":free"): + custom_llm_provider = "openrouter" if not custom_llm_provider: if litellm.suppress_debug_info is False: print() # noqa diff --git a/tests/local_testing/test_get_llm_provider.py b/tests/local_testing/test_get_llm_provider.py index 9b07111ea54..c8922446b4a 100644 --- a/tests/local_testing/test_get_llm_provider.py +++ b/tests/local_testing/test_get_llm_provider.py @@ -420,3 +420,14 @@ def test_get_llm_provider_use_proxy_arg_true_with_direct_args(): assert provider == "litellm_proxy" assert key == arg_api_key # Should use the argument key assert base == arg_api_base # Should use the argument base + + +def test_openrouter_free_model(): + """ + Test that models ending in :free are routed to openrouter + """ + model, custom_llm_provider, _, _ = litellm.get_llm_provider( + model="google/gemma-3-27b-it:free", + ) + assert custom_llm_provider == "openrouter" + assert model == "google/gemma-3-27b-it:free"