Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ UPSTREAM_API_KEY=your-upstream-api-key
# BASE_URL=https://openrouter.ai/api/v1
# MODELS_PATH=models.json
# SOURCE=
# EXCLUDED_MODEL_IDS="openrouter/auto,google/gemini-2.5-pro-exp-03-25,opengvlab/internvl3-78b"
14 changes: 12 additions & 2 deletions routstr/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Config:

@classmethod
def parse_env_var(cls, field_name: str, raw_value: str) -> Any: # type: ignore[override]
if field_name in {"cashu_mints", "cors_origins", "relays"}:
if field_name in {"cashu_mints", "cors_origins", "relays", "excluded_model_ids"}:
v = str(raw_value).strip()
if v == "":
return []
Expand Down Expand Up @@ -54,6 +54,16 @@ def parse_env_var(cls, field_name: str, raw_value: str) -> Any: # type: ignore[
# Minimum per-request charge in millisatoshis when model pricing is free/zero
min_request_msat: int = Field(default=1, env="MIN_REQUEST_MSAT")

# Model filtering
excluded_model_ids: list[str] = Field(
default_factory=lambda: [
"openrouter/auto",
"google/gemini-2.5-pro-exp-03-25",
"opengvlab/internvl3-78b"
],
env="EXCLUDED_MODEL_IDS"
)

# Network
cors_origins: list[str] = Field(default_factory=lambda: ["*"], env="CORS_ORIGINS")
tor_proxy_url: str = Field(default="socks5://127.0.0.1:9050", env="TOR_PROXY_URL")
Expand Down Expand Up @@ -304,4 +314,4 @@ async def reload_from_db(cls, db_session: AsyncSession) -> Settings:
for k, v in data.items():
setattr(settings, k, v)
cls._current = settings
return settings
return settings
11 changes: 8 additions & 3 deletions routstr/payment/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ def fetch_openrouter_models(source_filter: str | None = None) -> list[dict]:
model["id"] = model_id[len(source_prefix) :]
model_id = model["id"]

# Check if model should be excluded based on configuration
try:
excluded_ids = getattr(settings, "excluded_model_ids", [])
except Exception:
excluded_ids = []

if (
"(free)" in model.get("name", "")
or model_id == "openrouter/auto"
or model_id == "google/gemini-2.5-pro-exp-03-25"
or model_id in excluded_ids
):
continue

Expand Down Expand Up @@ -448,4 +453,4 @@ async def refresh_models_periodically() -> None:
@models_router.get("/models", include_in_schema=False)
async def models(session: AsyncSession = Depends(get_session)) -> dict:
items = await list_models(session)
return {"data": items}
return {"data": items}
Loading