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

@ -91,7 +91,8 @@ class ModelRateRegistry:
return ModelRateRegistry(merged)
_DEFAULT_RATES: dict[str, tuple[float, float]] = {
# prompt_per_1k, completion_per_1k, optional captured_at override
_DEFAULT_RATES: dict[str, tuple[float, float] | tuple[float, float, str]] = {
"openai/gpt-4o-mini": (0.00015, 0.00060),
"openai/gpt-4o": (0.0025, 0.01),
"openai/gpt-4-turbo": (0.01, 0.03),
@ -101,21 +102,28 @@ _DEFAULT_RATES: dict[str, tuple[float, float]] = {
"google/gemini-1.5-flash": (0.000075, 0.0003),
"google/gemini-1.5-pro": (0.00125, 0.005),
"meta-llama/llama-3.1-70b-instruct": (0.00059, 0.00079),
# OpenRouter list price 2026-08-03: $0.000003/prompt token, $0.000015/completion
"moonshotai/kimi-k3": (0.003, 0.015, "2026-08-03"),
}
def _default_rate_payload() -> dict[str, ModelRate]:
return {
model_id: ModelRate(
rates: dict[str, ModelRate] = {}
for model_id, values in _DEFAULT_RATES.items():
if len(values) == 3:
prompt_rate, completion_rate, captured_at = values # type: ignore[misc]
else:
prompt_rate, completion_rate = values # type: ignore[misc]
captured_at = DEFAULT_RATE_CAPTURED_AT
rates[model_id] = ModelRate(
model_id=model_id,
prompt_per_1k=prompt_rate,
completion_per_1k=completion_rate,
currency=DEFAULT_RATE_CURRENCY,
source_url=DEFAULT_RATE_SOURCE_URL,
captured_at=DEFAULT_RATE_CAPTURED_AT,
captured_at=str(captured_at),
)
for model_id, (prompt_rate, completion_rate) in _DEFAULT_RATES.items()
}
return rates
def _coerce_rate(model_id: str, rate: ModelRate | Mapping[str, Any]) -> ModelRate: