feat: per-config token pricing and 7-day spend rollup on /admin/configs #53
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/per-config-spend"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds two nullable NUMERIC columns to model_configs (input_per_mtok,
output_per_mtok), exposed via the create/update form on /admin/configs
as "Input/Output cost per million tokens (USD)". Set them per config
and the admin page projects token usage × rate over the last 7 days
into a per-config dollar figure.
Configs without rates intentionally show "—" rather than $0 — admins
haven't told us what to multiply by, and showing $0 would imply
"free" and bury the absence of data. Self-hosted vLLM configs with no
real per-token cost can stay un-priced for the same reason.
Numbers on the dashboard are an estimate, not the bill: no batch
discount accounting, no prompt-cache hit tracking. Lossy by a few %
on the way down. Useful for "is the Opus shadow eating into the
budget" type decisions without leaving the dashboard.
The lookback window is currently a const (SpendWindow = 7d) — bump
in code if 7 days proves too short or too long.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Automated review by pr-reviewer v0.21.2 | Safety Check | Claude Sonnet 4 | tracking id
r-f48c0a-16f36fThis is an AI-generated reveiw and may contain mistakes.
Status: ✅ Completed
✅ Verdict: LGTM — Code looks correct with proper handling of nullable pricing fields and reasonable SQL migration structure.
Complexity: moderate
Nothing alarming found. The changes add pricing tracking functionality with:
The logic for excluding configs without rates (showing "—" instead of "$0") is sensible to avoid misleading admins about costs.