Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(backend): correct stale OpenRouter display prices in the LLM catalog (SECRT-2701) (#14746)

Bentlyae4c5845f969
diff --git a/autogpt_platform/backend/backend/copilot/moonshot.py b/autogpt_platform/backend/backend/copilot/moonshot.py
index 8e9d322911..24a8357c78 100644
--- a/autogpt_platform/backend/backend/copilot/moonshot.py
+++ b/autogpt_platform/backend/backend/copilot/moonshot.py
@@ -34,7 +34,7 @@ Detection is prefix-based (``moonshotai/``). Moonshot routes every Kimi
SKU through the same Anthropic-compat surface, so a new slug transparently
inherits both the rate card and the cache-control gate without editing
this file. SKUs priced off the shared K2.x default (Kimi K3 broke the
-uniform pricing at 5x) carry per-slug entries in
+uniform pricing at ~3x) carry per-slug entries in
:data:`_RATE_OVERRIDES_USD_PER_MTOK`.
"""
@@ -60,7 +60,7 @@ def _overrides_from_catalog() -> dict[str, tuple[float, float]]:
"""Per-slug USD overrides for SKUs priced off the shared K2.x default.
Authored in the catalog (``provider_*_usd_per_1m`` on the model's cost
- entry — e.g. Kimi K3's $3/$15); slugs without them fall back to
+ entry — e.g. Kimi K3's $1.70/$8.50); slugs without them fall back to
:data:`_DEFAULT_MOONSHOT_RATE_USD_PER_MTOK`.
"""
return {
diff --git a/autogpt_platform/backend/backend/copilot/moonshot_test.py b/autogpt_platform/backend/backend/copilot/moonshot_test.py
index 762b39fcb2..8b881ab1b2 100644
--- a/autogpt_platform/backend/backend/copilot/moonshot_test.py
+++ b/autogpt_platform/backend/backend/copilot/moonshot_test.py
@@ -58,9 +58,14 @@ class TestRateCardUsd:
assert rate_card_usd("moonshotai/kimi-k2.6") == (0.60, 2.80)
def test_kimi_k3_premium_override(self) -> None:
- # K3 is split-priced ($3/$15 per Mtok) — the override must win
- # over the shared K2.x default.
- assert rate_card_usd("moonshotai/kimi-k3") == (3.00, 15.00)
+ # K3 is split-priced ($1.70/$8.50 per Mtok) — the override must win
+ # over the shared K2.x default. Sourced from the catalog entry's
+ # provider_*_usd_per_1m, which tracks OpenRouter's published price
+ # for moonshotai/kimi-k3 (/api/v1/models, re-checked 2026-09-20).
+ # It was $3/$15 until SECRT-2701: that is Moonshot AI's own
+ # first-party endpoint (and the :batch SKU), not the default route
+ # — we pin no provider, so OpenRouter picks the cheapest endpoint.
+ assert rate_card_usd("moonshotai/kimi-k3") == (1.70, 8.50)
def test_future_moonshot_sku_inherits_default(self) -> None:
# Verifies the prefix-based fallback — new SKUs don't need a code
diff --git a/autogpt_platform/backend/backend/data/block_cost_config_test.py b/autogpt_platform/backend/backend/data/block_cost_config_test.py
index 80f603224b..1b35b128a1 100644
--- a/autogpt_platform/backend/backend/data/block_cost_config_test.py
+++ b/autogpt_platform/backend/backend/data/block_cost_config_test.py
@@ -1,5 +1,6 @@
import pytest
+from backend.blocks._base import BlockCostType
from backend.blocks.ayrshare.post_to_bluesky import PostToBlueskyBlock
from backend.blocks.ayrshare.post_to_facebook import PostToFacebookBlock
from backend.blocks.ayrshare.post_to_gmb import PostToGMBBlock
@@ -21,14 +22,17 @@ from backend.blocks.code_executor import (
)
from backend.blocks.fal.ai_video_generator import AIVideoGeneratorBlock
from backend.blocks.jina.chunking import JinaChunkingBlock
+from backend.blocks.llm import AITextGeneratorBlock, LLMModel
from backend.blocks.youtube import TranscribeYoutubeVideoBlock
from backend.data.block_cost_config import BLOCK_COSTS
+from backend.data.model import NodeExecutionStats
from backend.executor import utils as executor_utils
from backend.executor.utils import block_usage_cost
from backend.integrations.credentials_store import (
e2b_credentials,
fal_credentials,
jina_credentials,
+ open_router_credentials,
webshare_proxy_credentials,
)
@@ -184,3 +188,64 @@ def test_transcribe_youtube_has_one_credit_tooling_floor():
},
)
assert cost == 1
+
+
+# -------- SECRT-2701: OpenRouter display rates are not billing rates --------
+
+
+def _open_router_input(model: str) -> dict:
+ return {
+ "model": model,
+ "credentials": {
+ "id": open_router_credentials.id,
+ "provider": open_router_credentials.provider,
+ "type": open_router_credentials.type,
+ },
+ }
+
+
+def test_open_router_bills_cost_usd_not_the_displayed_token_rate():
+ """open_router models settle against the provider's own x-total-cost, so
+ the catalog's per-1M credit rates only ever reach the builder's price
+ label. Pinning this keeps a refactor from quietly routing these models
+ down the TOKENS branch, which WOULD turn the displayed figures into
+ charges — and they drift against OpenRouter by design.
+ """
+ entry = next(
+ c
+ for c in BLOCK_COSTS[AITextGeneratorBlock]
+ if c.cost_filter.get("model") == LLMModel("deepseek/deepseek-chat")
+ )
+ assert entry.cost_type == BlockCostType.COST_USD
+ assert entry.cost_amount == 150
+
+ # A turn OpenRouter billed at $0.10 costs ceil(0.10 * 150) = 15 credits,
+ # whatever the displayed per-1M rates happen to say. The token counts
+ # below are deliberately huge: had this model been token-billed they
+ # would have produced 48 + 133.5 credits instead.
+ stats = NodeExecutionStats(
+ provider_cost=0.10,
+ provider_cost_type="cost_usd",
+ input_token_count=1_000_000,
+ output_token_count=1_000_000,
+ )
+ cost, _ = block_usage_cost(
+ AITextGeneratorBlock(),
+ _open_router_input("deepseek/deepseek-chat"),
+ stats=stats,
+ )
+ assert cost == 15
+
+
+def test_open_router_display_rate_matches_the_catalog_entry():
+ """The builder's "$X in / $Y out per 1M" label is the catalog credit rate
+ divided by the 150 cr/$ margin — SECRT-2701's corrected deepseek figures.
+ """
+ entry = next(
+ c
+ for c in BLOCK_COSTS[AITextGeneratorBlock]
+ if c.cost_filter.get("model") == LLMModel("deepseek/deepseek-chat")
+ )
+ assert entry.token_rate is not None
+ assert entry.token_rate.input_usd_per_1m == pytest.approx(0.32)
+ assert entry.token_rate.output_usd_per_1m == pytest.approx(0.89)
diff --git a/autogpt_platform/backend/backend/data/llm_registry/catalog.py b/autogpt_platform/backend/backend/data/llm_registry/catalog.py
index ae5c62f950..928f5fed37 100644
--- a/autogpt_platform/backend/backend/data/llm_registry/catalog.py
+++ b/autogpt_platform/backend/backend/data/llm_registry/catalog.py
@@ -386,6 +386,14 @@ def _build_catalog() -> CatalogPayload:
cost=CatalogModelCost(run_credits=1),
),
# ----- OpenRouter -----
+ # OpenRouter entries bill via COST_USD against the response's
+ # x-total-cost at 150 cr/$ (block_cost_config._open_router_llm_cost
+ # -> executor/utils.py COST_USD branch), so input/output_credits_per_1m
+ # below are DISPLAY ONLY — they fill the builder's "$X in / $Y out
+ # per 1M" label and never reach a charge. OpenRouter reprices
+ # continuously, so these drift by design; regenerate the comparison
+ # with:
+ # python3 scripts/check_openrouter_prices.py
CatalogModel(
slug="amazon/nova-lite-v1",
display_name="Nova Lite V1",
@@ -469,7 +477,9 @@ def _build_catalog() -> CatalogPayload:
max_output_tokens=2048,
price_tier=1,
cost=CatalogModelCost(
- run_credits=2, input_credits_per_1m=21.0, output_credits_per_1m=42.0
+ run_credits=2,
+ input_credits_per_1m=48.0,
+ output_credits_per_1m=133.5,
),
),
CatalogModel(
@@ -481,7 +491,9 @@ def _build_catalog() -> CatalogPayload:
max_output_tokens=163840,
price_tier=1,
cost=CatalogModelCost(
- run_credits=1, input_credits_per_1m=21.0, output_credits_per_1m=42.0
+ run_credits=1,
+ input_credits_per_1m=75.0,
+ output_credits_per_1m=322.5,
),
),
CatalogModel(
@@ -559,7 +571,7 @@ def _build_catalog() -> CatalogPayload:
price_tier=2,
cost=CatalogModelCost(
run_credits=4,
- input_credits_per_1m=188.0,
+ input_credits_per_1m=187.5,
output_credits_per_1m=1500.0,
),
),
@@ -587,7 +599,7 @@ def _build_catalog() -> CatalogPayload:
price_tier=1,
cost=CatalogModelCost(
run_credits=1,
- input_credits_per_1m=38.0,
+ input_credits_per_1m=37.5,
output_credits_per_1m=225.0,
),
),
@@ -658,8 +670,8 @@ def _build_catalog() -> CatalogPayload:
price_tier=1,
cost=CatalogModelCost(
run_credits=1,
- input_credits_per_1m=75.0,
- output_credits_per_1m=116.0,
+ input_credits_per_1m=28.125,
+ output_credits_per_1m=97.875,
),
),
CatalogModel(
@@ -671,7 +683,7 @@ def _build_catalog() -> CatalogPayload:
max_output_tokens=131072,
price_tier=1,
cost=CatalogModelCost(
- run_credits=1, input_credits_per_1m=17.0, output_credits_per_1m=51.0
+ run_credits=1, input_credits_per_1m=15.0, output_credits_per_1m=45.0
),
),
CatalogModel(
@@ -767,7 +779,9 @@ def _build_catalog() -> CatalogPayload:
max_output_tokens=131072,
price_tier=1,
cost=CatalogModelCost(
- run_credits=1, input_credits_per_1m=15.0, output_credits_per_1m=45.0
+ run_credits=1,
+ input_credits_per_1m=14.0625,
+ output_credits_per_1m=37.5,
),
),
CatalogModel(
@@ -794,8 +808,8 @@ def _build_catalog() -> CatalogPayload:
price_tier=1,
cost=CatalogModelCost(
run_credits=1,
- input_credits_per_1m=66.0,
- output_credits_per_1m=300.0,
+ input_credits_per_1m=67.5,
+ output_credits_per_1m=337.5,
),
),
CatalogModel(
@@ -808,8 +822,8 @@ def _build_catalog() -> CatalogPayload:
price_tier=2,
cost=CatalogModelCost(
run_credits=2,
- input_credits_per_1m=112.0,
- output_credits_per_1m=698.0,
+ input_credits_per_1m=142.5,
+ output_credits_per_1m=600.0,
),
),
CatalogModel(
@@ -826,15 +840,14 @@ def _build_catalog() -> CatalogPayload:
price_tier=3,
supports_tools=True,
supports_reasoning=True,
- # Moonshot's premium tier — $3/$15 per Mtok on OpenRouter,
- # credit rates at the standard 1.5x margin (Sonnet-class
- # pricing).
+ # Moonshot's premium tier — $1.70/$8.50 per Mtok on
+ # OpenRouter, credit rates at the standard 1.5x margin.
cost=CatalogModelCost(
run_credits=9,
- input_credits_per_1m=450.0,
- output_credits_per_1m=2250.0,
- provider_input_usd_per_1m=3.00,
- provider_output_usd_per_1m=15.00,
+ input_credits_per_1m=255.0,
+ output_credits_per_1m=1275.0,
+ provider_input_usd_per_1m=1.70,
+ provider_output_usd_per_1m=8.50,
),
),
CatalogModel(
@@ -866,7 +879,7 @@ def _build_catalog() -> CatalogPayload:
max_output_tokens=131072,
price_tier=1,
cost=CatalogModelCost(
- run_credits=1, input_credits_per_1m=23.0, output_credits_per_1m=90.0
+ run_credits=1, input_credits_per_1m=22.5, output_credits_per_1m=90.0
),
),
CatalogModel(
@@ -878,7 +891,7 @@ def _build_catalog() -> CatalogPayload:
max_output_tokens=32768,
price_tier=1,
cost=CatalogModelCost(
- run_credits=1, input_credits_per_1m=11.0, output_credits_per_1m=45.0
+ run_credits=1, input_credits_per_1m=4.5, output_credits_per_1m=19.5
),
),
CatalogModel(
@@ -1033,8 +1046,8 @@ def _build_catalog() -> CatalogPayload:
price_tier=3,
cost=CatalogModelCost(
run_credits=5,
- input_credits_per_1m=300.0,
- output_credits_per_1m=900.0,
+ input_credits_per_1m=187.5,
+ output_credits_per_1m=375.0,
),
),
CatalogModel(
diff --git a/autogpt_platform/backend/backend/data/llm_registry/catalog_test.py b/autogpt_platform/backend/backend/data/llm_registry/catalog_test.py
index 8cc2043196..34bde9d2db 100644
--- a/autogpt_platform/backend/backend/data/llm_registry/catalog_test.py
+++ b/autogpt_platform/backend/backend/data/llm_registry/catalog_test.py
@@ -81,6 +81,17 @@ def test_routing_cells_reference_enabled_models():
_SNAPSHOT_PATH = Path(__file__).parent / "pre_catalog_costs_snapshot.json"
+# open_router models bill via COST_USD against the response's x-total-cost,
+# never from TOKEN_COST (block_cost_config._open_router_llm_cost). Their
+# per-1M rates are display only, and OpenRouter reprices continuously, so
+# pinning those values to the cutover snapshot pins a number that is
+# expected to drift and that no user is ever charged. Their *presence* in
+# the snapshot stays pinned by the absence-parity check below; only the
+# values are exempt. Every genuinely billed provider keeps full parity.
+_DISPLAY_ONLY_TOKEN_COST_SLUGS = frozenset(
+ m.slug for m in CATALOG.models if m.provider == "open_router"
+)
+
def test_billing_matches_pre_catalog_snapshot():
"""Cutover-parity proof: the catalog-derived cost dicts reproduce the
@@ -94,9 +105,12 @@ def test_billing_matches_pre_catalog_snapshot():
for slug, credits in snapshot["model_cost"].items():
assert MODEL_COST[LLMModel(slug)] == credits, slug
for slug, rate in snapshot["token_cost"].items():
+ if slug in _DISPLAY_ONLY_TOKEN_COST_SLUGS:
+ continue
assert TOKEN_COST[LLMModel(slug)].model_dump() == rate, slug
# Absence parity: the cutover itself must not silently move a model
- # between flat-rate and token billing.
+ # between flat-rate and token billing. Presence is still pinned for the
+ # display-only slugs above — only their values are allowed to move.
pre_cutover = set(snapshot["model_cost"])
token_billed = {m.value for m in TOKEN_COST}
assert token_billed & pre_cutover == set(snapshot["token_cost"])
@@ -130,8 +144,26 @@ def test_kimi_k3_bills_at_authored_rates():
k3 = LLMModel("moonshotai/kimi-k3")
assert MODEL_COST[k3] == 9
assert TOKEN_COST[k3].model_dump() == {
- "input": 450.0,
- "output": 2250.0,
+ "input": 255.0,
+ "output": 1275.0,
+ "cache_read": 0.0,
+ "cache_creation": 0.0,
+ }
+
+
+def test_deepseek_chat_display_rate_tracks_openrouter():
+ """SECRT-2701 regression pin: deepseek-chat's shown price had drifted to
+ ~3x understated ($0.14/$0.28 displayed against a live $0.32/$0.89) and
+ nothing caught it. These figures are display only — open_router settles
+ COST_USD against x-total-cost — but a wrong number shown before the user
+ picks a model is still wrong. Re-derive with
+ ``poetry run python scripts/check_openrouter_prices.py`` and move both
+ sides together when OpenRouter reprices.
+ """
+ chat = LLMModel("deepseek/deepseek-chat")
+ assert TOKEN_COST[chat].model_dump() == {
+ "input": 48.0, # $0.32/1M x 150 cr/$
+ "output": 133.5, # $0.89/1M x 150 cr/$
"cache_read": 0.0,
"cache_creation": 0.0,
}
diff --git a/autogpt_platform/backend/scripts/check_openrouter_prices.py b/autogpt_platform/backend/scripts/check_openrouter_prices.py
new file mode 100644
index 0000000000..8b76422198
--- /dev/null
+++ b/autogpt_platform/backend/scripts/check_openrouter_prices.py
@@ -0,0 +1,219 @@
+"""Compare the catalog's OpenRouter display prices against OpenRouter live.
+
+``open_router`` catalog entries bill via ``COST_USD`` against the response's
+``x-total-cost`` (see ``block_cost_config._open_router_llm_cost``), so their
+``input_credits_per_1m`` / ``output_credits_per_1m`` are **display only** —
+they feed ``_token_rate_display`` and the builder's "$X in / $Y out per 1M"
+label, never a charge. OpenRouter reprices continuously, so these figures
+drift by design; this script reports the drift instead of leaving the next
+person to rediscover it.
+
+Run manually::
+
+ poetry run python scripts/check_openrouter_prices.py
+
+Reads ``catalog.py`` with ``ast`` rather than importing the backend, so it
+runs without a configured environment. A slug missing from
+``/api/v1/models`` is not necessarily gone: OpenRouter keeps serving
+renamed models that only the per-model ``/endpoints`` route lists, so
+missing slugs are probed there before being called unavailable.
+
+Exits 1 when any listed model's display rate differs from the live price.
+"""
+
+from __future__ import annotations
+
+import argparse
+import ast
+import json
+import sys
+import urllib.error
+import urllib.request
+from pathlib import Path
+from typing import Any
+
+# 100 credits/$ x 1.5 margin; mirrors block_cost_config._USD_PER_1M_DIVISOR.
+CREDITS_PER_USD = 150
+_MODELS_URL = "https://openrouter.ai/api/v1/models"
+_ENDPOINTS_URL = "https://openrouter.ai/api/v1/models/%s/endpoints"
+_CATALOG_PATH = (
+ Path(__file__).resolve().parents[1]
+ / "backend"
+ / "data"
+ / "llm_registry"
+ / "catalog.py"
+)
+
+
+def _literal(node: ast.AST | None) -> Any:
+ try:
+ return ast.literal_eval(node) # type: ignore[arg-type]
+ except (ValueError, TypeError, SyntaxError):
+ return None
+
+
+def catalog_models(path: Path) -> list[dict[str, Any]]:
+ """Every ``open_router`` CatalogModel with its authored credit rates."""
+ tree = ast.parse(path.read_text(encoding="utf-8"))
+ out: list[dict[str, Any]] = []
+ for node in ast.walk(tree):
+ if not (
+ isinstance(node, ast.Call)
+ and getattr(node.func, "id", "") == "CatalogModel"
+ ):
+ continue
+ kw = {k.arg: k.value for k in node.keywords}
+ if _literal(kw.get("provider")) != "open_router":
+ continue
+ entry: dict[str, Any] = {
+ "slug": _literal(kw.get("slug")),
+ "line": node.lineno,
+ "input_credits_per_1m": None,
+ "output_credits_per_1m": None,
+ }
+ cost = kw.get("cost")
+ if isinstance(cost, ast.Call):
+ ckw = {k.arg: k.value for k in cost.keywords}
+ for field in ("input_credits_per_1m", "output_credits_per_1m"):
+ entry[field] = _literal(ckw.get(field))
+ out.append(entry)
+ return out
+
+
+def _probe_endpoints(slug: str) -> tuple[str, dict[str, Any] | None]:
+ """Classify a slug that /api/v1/models does not list.
+
+ ``REMOVED`` (404), ``ALIASED`` (renamed but still served — its pricing is
+ returned), or ``NO_ENDPOINTS`` (known but nothing serving it).
+ """
+ try:
+ with urllib.request.urlopen(_ENDPOINTS_URL % slug, timeout=60) as resp:
+ data = json.load(resp)["data"]
+ except urllib.error.HTTPError as exc:
+ return ("REMOVED" if exc.code == 404 else "PROBE_ERROR"), None
+ except (urllib.error.URLError, KeyError, ValueError):
+ return "PROBE_ERROR", None
+ endpoints = data.get("endpoints") or []
+ if not endpoints:
+ return "NO_ENDPOINTS", None
+ cheapest = min(endpoints, key=lambda e: float(e["pricing"]["prompt"]))
+ return "ALIASED", {"pricing": cheapest["pricing"], "alias_of": data.get("id")}
+
+
+def compare(
+ catalog_path: Path, models_json: Path | None = None
+) -> list[dict[str, Any]]:
+ if models_json is not None:
+ live_raw = json.loads(models_json.read_text(encoding="utf-8"))["data"]
+ else:
+ with urllib.request.urlopen(_MODELS_URL, timeout=60) as resp:
+ live_raw = json.load(resp)["data"]
+ live = {m["id"]: m for m in live_raw}
+
+ rows: list[dict[str, Any]] = []
+ for model in catalog_models(catalog_path):
+ row = dict(
+ model,
+ status="",
+ alias_of=None,
+ cat_input_usd=None,
+ cat_output_usd=None,
+ api_input_usd=None,
+ api_output_usd=None,
+ want_input_credits=None,
+ want_output_credits=None,
+ )
+ if model["input_credits_per_1m"] is not None:
+ row["cat_input_usd"] = model["input_credits_per_1m"] / CREDITS_PER_USD
+ row["cat_output_usd"] = model["output_credits_per_1m"] / CREDITS_PER_USD
+
+ api = live.get(model["slug"])
+ aliased = False
+ if api is None and models_json is None:
+ status, alias = _probe_endpoints(model["slug"])
+ row["status"] = status
+ if alias is not None:
+ row["alias_of"] = alias["alias_of"]
+ api = alias
+ aliased = True
+ if api is None:
+ row["status"] = row["status"] or "UNAVAILABLE"
+ rows.append(row)
+ continue
+
+ pricing = api.get("pricing", {})
+ row["api_input_usd"] = float(pricing.get("prompt", 0)) * 1e6
+ row["api_output_usd"] = float(pricing.get("completion", 0)) * 1e6
+ row["want_input_credits"] = round(row["api_input_usd"] * CREDITS_PER_USD, 4)
+ row["want_output_credits"] = round(row["api_output_usd"] * CREDITS_PER_USD, 4)
+ if model["input_credits_per_1m"] is None:
+ row["status"] = "NO_RATES"
+ elif (
+ abs(row["cat_input_usd"] - row["api_input_usd"]) < 1e-9
+ and abs(row["cat_output_usd"] - row["api_output_usd"]) < 1e-9
+ ):
+ row["status"] = "MATCH-ALIAS" if aliased else "MATCH"
+ else:
+ row["status"] = "DRIFT-ALIAS" if aliased else "DRIFT"
+ rows.append(row)
+ return rows
+
+
+def _fmt(lo: float | None, hi: float | None) -> str:
+ return "-" if lo is None else f"{lo:.6g} / {hi:.6g}"
+
+
+def main() -> int:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--catalog", type=Path, default=_CATALOG_PATH)
+ parser.add_argument(
+ "--models-json",
+ type=Path,
+ help="use a saved /api/v1/models response instead of fetching",
+ )
+ parser.add_argument("--json", dest="json_out", type=Path)
+ args = parser.parse_args()
+
+ rows = compare(args.catalog, args.models_json)
+ rows.sort(key=lambda r: (r["status"], r["slug"]))
+
+ width = max(len(r["slug"]) for r in rows) + 1
+ print(
+ f"{'slug':<{width}} {'status':<13} {'catalog $in/$out':>22} "
+ f"{'live $in/$out':>22} credits in/out (want)"
+ )
+ print("-" * (width + 94))
+ for row in rows:
+ want = (
+ "-"
+ if row["want_input_credits"] is None
+ else f"{row['want_input_credits']:g} / {row['want_output_credits']:g}"
+ )
+ print(
+ f"{row['slug']:<{width}} {row['status']:<13} "
+ f"{_fmt(row['cat_input_usd'], row['cat_output_usd']):>22} "
+ f"{_fmt(row['api_input_usd'], row['api_output_usd']):>22} {want}"
+ )
+
+ counts: dict[str, int] = {}
+ for row in rows:
+ counts[row["status"]] = counts.get(row["status"], 0) + 1
+ print(f"\ntotal open_router entries: {len(rows)}")
+ for status in sorted(counts):
+ print(f" {status}: {counts[status]}")
+
+ if args.json_out is not None:
+ args.json_out.write_text(json.dumps(rows, indent=2) + "\n", encoding="utf-8")
+
+ drifted = [r for r in rows if r["status"].startswith("DRIFT")]
+ if drifted:
+ print(
+ f"\n{len(drifted)} model(s) drifted from OpenRouter's live price.",
+ file=sys.stderr,
+ )
+ return 1
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())