fix(openrouter): automatically detect OpenRouter models with :free suffix

This commit is contained in:
Varun Sripad 2026-01-29 00:44:11 -06:00
parent f2d2ed5a0d
commit b9af50506e
2 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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"