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