fix(openrouter): remove litellm_prefix to prevent double-prefixed model names

With custom_llm_provider kwarg handling routing, the openrouter/ prefix
caused model names like anthropic/claude-sonnet-4-6 to become
openrouter/anthropic/claude-sonnet-4-6, which OpenRouter API rejects.
This commit is contained in:
Xubin Ren
2026-03-15 02:27:43 +00:00
committed by Xubin Ren
parent 5ccf350db1
commit 350d110fb9
2 changed files with 7 additions and 1 deletions

View File

@@ -98,7 +98,7 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
keywords=("openrouter",),
env_key="OPENROUTER_API_KEY",
display_name="OpenRouter",
litellm_prefix="openrouter", # claude-3 → openrouter/claude-3
litellm_prefix="", # routing handled by custom_llm_provider kwarg; no prefix needed
skip_prefixes=(),
env_extras=(),
is_gateway=True,

View File

@@ -45,6 +45,9 @@ async def test_openrouter_injects_litellm_kwargs() -> None:
assert call_kwargs.get("custom_llm_provider") == "openrouter", (
"OpenRouter gateway should pass custom_llm_provider='openrouter' to acompletion"
)
assert call_kwargs["model"] == "anthropic/claude-sonnet-4-5", (
"Model name must NOT get an 'openrouter/' prefix — routing is via custom_llm_provider"
)
@pytest.mark.asyncio
@@ -110,3 +113,6 @@ async def test_openrouter_autodetect_by_key_prefix() -> None:
assert call_kwargs.get("custom_llm_provider") == "openrouter", (
"Auto-detected OpenRouter (by sk-or- prefix) should still inject custom_llm_provider"
)
assert call_kwargs["model"] == "anthropic/claude-sonnet-4-5", (
"Auto-detected OpenRouter must preserve native model name without openrouter/ prefix"
)