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

@ -10,12 +10,16 @@ def test_known_model_cost_matches_lefevre_smoke_budget():
assert estimate.cost_source == "rate_table:openai/gpt-4o-mini"
assert estimate.cost_usd == pytest.approx(0.0087)
assert estimate.cost_usd == pytest.approx(0.009, rel=0.2)
assert estimate.cost_eur is not None
assert estimate.fx_source is not None
def test_unknown_model_returns_unknown_without_zeroing_cost():
estimate = estimate_cost("unknown/model", 100, 50)
assert estimate == CostEstimate(cost_usd=None, cost_source="unknown")
assert estimate.cost_usd is None
assert estimate.cost_eur is None
assert estimate.cost_source == "unknown"
def test_registry_override_controls_estimate():
@ -29,21 +33,40 @@ def test_registry_override_controls_estimate():
}
)
estimate = estimate_cost("vendor/model", 1_000, 500, registry=registry)
estimate = estimate_cost("vendor/model", 1_000, 500, registry=registry, fx=1.0)
assert estimate.cost_usd == pytest.approx(2.0)
assert estimate.prompt_cost_usd == pytest.approx(1.0)
assert estimate.completion_cost_usd == pytest.approx(1.0)
assert estimate.cost_eur == pytest.approx(2.0)
def test_zero_tokens_are_valid_and_cost_zero_for_known_model():
estimate = CostModel().estimate_cost("openai/gpt-4o-mini", 0, 0)
estimate = CostModel(fx=1.0).estimate_cost("openai/gpt-4o-mini", 0, 0)
assert estimate.cost_usd == 0
assert estimate.prompt_cost_usd == 0
assert estimate.completion_cost_usd == 0
assert estimate.cost_eur == 0
def test_negative_tokens_are_rejected():
with pytest.raises(ValueError, match="prompt_tokens"):
estimate_cost("openai/gpt-4o-mini", -1, 0)
def test_kimi_k3_rate_and_eur_conversion():
estimate = estimate_cost("moonshotai/kimi-k3", 1_000, 1_000, fx=0.92)
# $0.003 + $0.015 = $0.018; ×0.92 = €0.01656
assert estimate.cost_usd == pytest.approx(0.018)
assert estimate.cost_eur == pytest.approx(0.01656)
assert estimate.cost_source == "rate_table:moonshotai/kimi-k3"
def test_apply_fx_false_skips_eur():
estimate = estimate_cost("moonshotai/kimi-k3", 100, 0, apply_fx=False)
assert estimate.cost_usd is not None
assert estimate.cost_eur is None
assert estimate.fx_source is None