Skip to content

Your lightweight open-source personal agent.

refactor(openrouter): move litellm kwargs into registry

Paresh Mathur445e0aa2c4d0
diff --git a/nanobot/providers/litellm_provider.py b/nanobot/providers/litellm_provider.py
index 2bd58c78d..b359d77e6 100644
--- a/nanobot/providers/litellm_provider.py
+++ b/nanobot/providers/litellm_provider.py
@@ -249,10 +249,8 @@ class LiteLLMProvider(LLMProvider):
"temperature": temperature,
}
- # LiteLLM strips the `openrouter/` prefix unless the provider is
- # passed explicitly, which breaks native OpenRouter model IDs.
- if self._gateway and self._gateway.name == "openrouter":
- kwargs["custom_llm_provider"] = "openrouter"
+ if self._gateway:
+ kwargs.update(self._gateway.litellm_kwargs)
# Apply model-specific overrides (e.g. kimi-k2.5 temperature)
self._apply_model_overrides(model, kwargs)
diff --git a/nanobot/providers/registry.py b/nanobot/providers/registry.py
index 2c9c185c5..8d1cfbe5f 100644
--- a/nanobot/providers/registry.py
+++ b/nanobot/providers/registry.py
@@ -12,7 +12,7 @@ Every entry writes out all fields so you can copy-paste as a template.
from __future__ import annotations
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from typing import Any
@@ -47,6 +47,7 @@ class ProviderSpec:
# gateway behavior
strip_model_prefix: bool = False # strip "provider/" before re-prefixing
+ litellm_kwargs: dict[str, Any] = field(default_factory=dict) # extra kwargs passed to LiteLLM
# per-model param overrides, e.g. (("kimi-k2.5", {"temperature": 1.0}),)
model_overrides: tuple[tuple[str, dict[str, Any]], ...] = ()
@@ -106,6 +107,7 @@ PROVIDERS: tuple[ProviderSpec, ...] = (
detect_by_base_keyword="openrouter",
default_api_base="https://openrouter.ai/api/v1",
strip_model_prefix=False,
+ litellm_kwargs={"custom_llm_provider": "openrouter"},
model_overrides=(),
supports_prompt_caching=True,
),