mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix(openrouter): automatically detect OpenRouter models with :free suffix
This commit is contained in:
parent
f2d2ed5a0d
commit
b9af50506e
2 changed files with 13 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue