Implement LLM-WP-0008: provider-scoped account balance CLI
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s

Add pluggable balance registry, OpenRouter credits/key limit client,
and llm-connect balance with one-shot --provider that does not change
library defaults.
This commit is contained in:
tegwick 2026-08-03 23:49:01 +02:00
parent c0d5c4ad08
commit ed7c632155
11 changed files with 783 additions and 14 deletions

View file

@ -64,6 +64,11 @@ llm-connect cost estimate --model moonshotai/kimi-k3 \
llm-connect spend week # current week: Mon 00:00 → now
llm-connect spend week --last # previous week: Mon → Sun
llm-connect spend week --json
# Provider prepaid / key remaining (backend-scoped; does not change defaults)
llm-connect balance # current default provider
llm-connect balance --provider openrouter # one-shot backend select
llm-connect balance --json
```
Usage events append to a JSONL ledger (default
@ -71,6 +76,11 @@ Usage events append to a JSONL ledger (default
`LLM_CONNECT_USAGE_LEDGER`). Costs are list-price estimates (USD rate table +
EUR via snapshot or `LLM_CONNECT_EUR_PER_USD`).
`balance` is **provider-scoped**: it reports the selected backends prepaid /
key remaining (OpenRouter today). `--provider` applies only to that
invocation and does not switch the library default provider or model.
Unsupported backends fail clearly instead of falling back to OpenRouter.
| Env | Purpose |
|---|---|
| `LLM_CONNECT_USAGE_LEDGER` | Usage JSONL path; enables library/server auto-recording when set |