From 88ede807c4cab7c2235b4e205cb7ba3521ac1117 Mon Sep 17 00:00:00 2001 From: zccyman <16263913+zccyman@users.noreply.github.com> Date: Tue, 12 May 2026 15:04:18 -0700 Subject: [PATCH] fix(pricing): add deepseek-v4-pro to official docs pricing table deepseek-v4-pro has been routable since v0.12 but was missing from the _OFFICIAL_DOCS_PRICING table. Sessions using this model showed as "unknown cost" in hermes insights instead of a dollar estimate. Add pricing entry using published list prices: - input: \$1.74/M tokens - output: \$3.48/M tokens - cache_read: \$0.0145/M tokens Uses standard list rates (not the 75% promo) so estimates remain accurate after promo expires 2026-05-31. Closes #24218 --- agent/usage_pricing.py | 11 ++++++++++ tests/agent/test_usage_pricing.py | 34 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/agent/usage_pricing.py b/agent/usage_pricing.py index 467b72931c2..fcf4f622834 100644 --- a/agent/usage_pricing.py +++ b/agent/usage_pricing.py @@ -370,6 +370,17 @@ _OFFICIAL_DOCS_PRICING: Dict[tuple[str, str], PricingEntry] = { source_url="https://api-docs.deepseek.com/quick_start/pricing", pricing_version="deepseek-pricing-2026-03-16", ), + ( + "deepseek", + "deepseek-v4-pro", + ): PricingEntry( + input_cost_per_million=Decimal("1.74"), + output_cost_per_million=Decimal("3.48"), + cache_read_cost_per_million=Decimal("0.0145"), + source="official_docs_snapshot", + source_url="https://api-docs.deepseek.com/quick_start/pricing", + pricing_version="deepseek-pricing-2026-05-12", + ), # Google Gemini ( "google", diff --git a/tests/agent/test_usage_pricing.py b/tests/agent/test_usage_pricing.py index 5daace97dea..5c84b124a2e 100644 --- a/tests/agent/test_usage_pricing.py +++ b/tests/agent/test_usage_pricing.py @@ -190,3 +190,37 @@ def test_custom_endpoint_models_api_pricing_is_supported(monkeypatch): assert float(entry.input_cost_per_million) == 0.5 assert float(entry.output_cost_per_million) == 2.0 + + +def test_deepseek_v4_pro_pricing_entry_exists(): + """Regression test: deepseek-v4-pro must have a pricing entry. + + Before this fix, deepseek-v4-pro sessions showed as unknown cost + in hermes insights because the _OFFICIAL_DOCS_PRICING table had no + entry for that model. See #24218. + """ + entry = get_pricing_entry( + "deepseek-v4-pro", + provider="deepseek", + ) + + assert entry is not None + assert entry.input_cost_per_million is not None + assert entry.output_cost_per_million is not None + assert float(entry.input_cost_per_million) == 1.74 + assert float(entry.output_cost_per_million) == 3.48 + assert float(entry.cache_read_cost_per_million) == 0.0145 + + +def test_deepseek_v4_pro_estimate_usage_cost(): + """Ensure deepseek-v4-pro sessions get a dollar estimate, not unknown.""" + result = estimate_usage_cost( + "deepseek-v4-pro", + CanonicalUsage(input_tokens=1000000, output_tokens=500000), + provider="deepseek", + ) + + assert result.status == "estimated" + assert result.amount_usd is not None + # 1M input × $1.74/M + 500K output × $3.48/M = $1.74 + $1.74 = $3.48 + assert float(result.amount_usd) == 3.48