Skip to content

feat: require client keys and show each client's consumption - #23

Merged
klNuno merged 3 commits into
mainfrom
feat/client-stats-required
Oct 21, 2026
Merged

klNuno merged 3 commits into
mainfrom
feat/client-stats-required

Conversation

@klNuno

@klNuno klNuno commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Note

Clanker Claude Opus 5.5 is responding on behalf of meetsu

The Clients page now shows which client spends what, with or without limits, and douane refuses any call that does not carry a client key.

Consumption over 7 days, one client's models open

what changed

  • Every /v1 call and WebSocket needs a client key; with no client, douane answers 401 with how to create one (clients.rs).
  • The ledger sums calls, tokens, cache reads, errors and time by client, provider and model, and by client and hour (ledger.rs).
  • GET /admin/api/clients/stats?hours=N (1 to 2160, default 24) serves those sums (management.rs).
  • A Consumption section heads the Clients page: totals, a stacked tokens chart, a ranked row per client and per-model details (client-stats.svelte).
  • The startup log warns when no client exists, and the quick start, README and mock now use dk_... instead of the douane placeholder.

to question

A fresh install now serves nothing until a client exists. Requiring the key always is what makes every call attributable; the 401 message and the startup warning name the Clients page and douanectl client add.

verified

  • cargo test --workspace --all-targets --locked: 251 passed, including a ledger test for the sums and the HTTP clients test (401 before the first client, stats after a call, 401 again after the last client is deleted).
  • pnpm check: 0 errors, 0 warnings; pnpm build committed.
  • Captures from pnpm mock at 1440 px and 390 px, opened and checked.
  • not verified: the page against a real ledger; that comes with the N1 deploy.

captures

24 hours, hourly columns:

Consumption over 24 hours

Phone, 390 px:

Consumption on a phone

…mption

No client means no access: every /v1 call needs a client key, so every call is counted for its client. The Clients page gains a Consumption section (24 h, 7 or 30 days): tokens, calls, cache reads, errors and part of the total per client, tokens over time, and per-model details. GET /admin/api/clients/stats serves the totals.
@klNuno
klNuno merged commit 17a4165 into main Oct 21, 2026
11 checks passed
@klNuno
klNuno deleted the feat/client-stats-required branch October 21, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant