diff --git a/agent/usage_pricing.py b/agent/usage_pricing.py index 99af6343de21..e1763046ff0f 100644 --- a/agent/usage_pricing.py +++ b/agent/usage_pricing.py @@ -477,6 +477,17 @@ _OFFICIAL_DOCS_PRICING: Dict[tuple[str, str], PricingEntry] = { source_url="https://api-docs.deepseek.com/quick_start/pricing", pricing_version="deepseek-pricing-2026-05-12", ), + ( + "deepseek", + "deepseek-v4-flash", + ): PricingEntry( + input_cost_per_million=Decimal("0.14"), + output_cost_per_million=Decimal("0.28"), + cache_read_cost_per_million=Decimal("0.0028"), + 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 7523931299e5..4b1d9f7e55dd 100644 --- a/tests/agent/test_usage_pricing.py +++ b/tests/agent/test_usage_pricing.py @@ -415,3 +415,37 @@ def test_fireworks_rows_all_carry_cache_read_pricing(): entry = _OFFICIAL_DOCS_PRICING[key] assert entry.cache_read_cost_per_million is not None, key assert entry.cache_read_cost_per_million < entry.input_cost_per_million, key + + +def test_deepseek_v4_flash_pricing_entry_exists(): + """Regression test: deepseek-v4-flash must have a pricing entry. + + Before this fix, deepseek-v4-flash sessions showed $0.00 / cost_source + "none" because the _OFFICIAL_DOCS_PRICING table had an entry for + deepseek-v4-pro but not the (newer) flash model. DeepSeek's /models + endpoint returns no pricing, so the official-docs snapshot is the only + source for direct-provider routes. + """ + entry = get_pricing_entry( + "deepseek-v4-flash", + provider="deepseek", + ) + + assert entry is not None + assert float(entry.input_cost_per_million) == 0.14 + assert float(entry.output_cost_per_million) == 0.28 + assert float(entry.cache_read_cost_per_million) == 0.0028 + + +def test_deepseek_v4_flash_estimate_usage_cost(): + """Ensure deepseek-v4-flash sessions get a dollar estimate, not $0/none.""" + result = estimate_usage_cost( + "deepseek-v4-flash", + CanonicalUsage(input_tokens=1000000, output_tokens=500000), + provider="deepseek", + ) + + assert result.status == "estimated" + assert result.amount_usd is not None + # 1M input × $0.14/M + 500K output × $0.28/M = $0.14 + $0.14 = $0.28 + assert float(result.amount_usd) == 0.28