Implement LLM-WP-0007: Kimi K3 default and EUR spend reporting
Some checks failed
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Has been cancelled

Add moonshotai/kimi-k3 as OpenRouter basemodel default after live smoke,
USD→EUR cost conversion, append-only usage ledger, and CLI run/cost/spend
week commands with token and euro reporting.
This commit is contained in:
tegwick 2026-08-03 22:00:34 +02:00
parent f3121c3f1f
commit 09aa1f3604
21 changed files with 1396 additions and 103 deletions

View file

@ -1,7 +1,8 @@
# Cost Estimates
`llm_connect.costs` converts token estimates or observed token counts into
USD estimates using `ModelRateRegistry`.
USD estimates using `ModelRateRegistry`, and optionally into EUR via
`llm_connect.fx`.
## Contract
@ -9,6 +10,7 @@ USD estimates using `ModelRateRegistry`.
from llm_connect import estimate_cost
estimate = estimate_cost("openai/gpt-4o-mini", 28_000, 7_500)
estimate = estimate_cost("moonshotai/kimi-k3", 1_000, 500, fx=0.92)
```
For known models the result is:
@ -17,9 +19,16 @@ For known models the result is:
- `prompt_cost_usd`: prompt-token component.
- `completion_cost_usd`: completion-token component.
- `cost_source`: `rate_table:<model_id>`.
- `cost_eur` / `prompt_cost_eur` / `completion_cost_eur`: EUR display amounts
when FX is available (default: bundled snapshot, override with `fx=` or
env `LLM_CONNECT_EUR_PER_USD` as euros-per-USD).
- `fx_source`: how EUR was derived (`explicit`, `env:…`, `snapshot:…`).
Unknown models return `CostEstimate(cost_usd=None, cost_source="unknown")`.
Missing rates are never silently treated as zero cost.
Unknown models return `CostEstimate(cost_usd=None, cost_source="unknown")`
with EUR fields also `None`. Missing rates or FX are never silently treated
as zero cost.
The module also exposes `CostModel(registry=...)` for callers that prefer to
carry a registry object and call `model.estimate_cost(...)`.
Pass `apply_fx=False` to skip EUR conversion.
The module also exposes `CostModel(registry=..., fx=...)` for callers that
prefer to carry a registry object and call `model.estimate_cost(...)`.