feat: per-config token pricing and 7-day spend rollup on /admin/configs #53

Merged
rcsheets merged 1 commit from feat/per-config-spend into main 2026-05-01 11:24:27 +00:00
Owner

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

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>
feat: per-config token pricing and 7-day spend rollup on /admin/configs
All checks were successful
ci / check (pull_request) Successful in 44s
6b30f59875
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>
Collaborator

Automated review by pr-reviewer v0.21.2 | Safety Check | Claude Sonnet 4 | tracking id r-f48c0a-16f36f
This 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:

  • Clean database migration with proper nullable NUMERIC columns and comments
  • Proper handling of NULL values using sql.NullFloat64 for optional pricing fields
  • Safe float parsing with error checking in form handling
  • SQL query looks correct with proper joins and NULL checks to exclude configs without pricing

The logic for excluding configs without rates (showing "—" instead of "$0") is sensible to avoid misleading admins about costs.

*Automated review by [pr-reviewer](https://git.brooktrails.org/brooktrails/pr-reviewer) v0.21.2 | Safety Check | Claude Sonnet 4 | tracking id `r-f48c0a-16f36f`* *This 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: - Clean database migration with proper nullable NUMERIC columns and comments - Proper handling of NULL values using sql.NullFloat64 for optional pricing fields - Safe float parsing with error checking in form handling - SQL query looks correct with proper joins and NULL checks to exclude configs without pricing The logic for excluding configs without rates (showing "—" instead of "$0") is sensible to avoid misleading admins about costs.
rcsheets deleted branch feat/per-config-spend 2026-05-01 11:24:27 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
brooktrails/pr-reviewer!53
No description provided.