diff --git a/app/main.py b/app/main.py index 2d56eba..60237ba 100644 --- a/app/main.py +++ b/app/main.py @@ -1521,7 +1521,11 @@ async def broker_get_usage(email: str) -> dict: for row in rows if isinstance(rows, list) else []: if row.get("team_id") != team_id: continue - model = row.get("model") or "unknown" + # Prefer model_group: it carries our provider/model alias (e.g. + # greenpt/green-r) when present; the raw `model` field holds + # messy upstream/internal names. Older rows predating the alias + # convention have model_group empty, so fall back to `model`. + model = row.get("model_group") or row.get("model") or "unknown" m = models.setdefault(model, {"spend": 0.0, "tokens": 0, "calls": 0}) m["spend"] += float(row.get("spend") or 0.0) m["tokens"] += int(row.get("total_tokens") or 0)