feat(model_catalog): add DeepSeek V4 Pro and V4 Flash

Both models accepted by DeepSeek /chat/completions but absent from the
LiteLLM catalog, so get_model_info() and completion_cost() return nothing.

Source: https://api-docs.deepseek.com/quick_start/pricing
- deepseek-v4-flash: $0.14 / $0.28 per 1M input/output, cache hit $0.0028
- deepseek-v4-pro:   $1.74 / $3.48 per 1M input/output, cache hit $0.0145
  (V4 Pro standard tier; 75% discount until 2026-05-31 not encoded.)

Context: 1M input / 384K output, encoded as binary K (1048576 / 393216) to
match existing DeepSeek family (deepseek/deepseek-chat=131072,
deepseek/deepseek-v3.2=163840).

Capability flags mirror existing deepseek/deepseek-chat entry, with
supports_reasoning=true since both V4 variants ship thinking modes.

Updates both model_prices_and_context_window.json and the bundled
litellm/model_prices_and_context_window_backup.json. Adds metadata
regression test in tests/test_litellm/ with presence, field-value, and
main<->backup sync assertions.
This commit is contained in:
vfpdev 2026-05-20 12:55:35 +02:00
parent a72414a061
commit 0a106aa674
3 changed files with 164 additions and 0 deletions

View file

@ -12899,6 +12899,56 @@
"supports_reasoning": true,
"supports_tool_choice": true
},
"deepseek/deepseek-v4-flash": {
"cache_creation_input_token_cost": 0.0,
"cache_read_input_token_cost": 2.8e-09,
"input_cost_per_token": 1.4e-07,
"input_cost_per_token_cache_hit": 2.8e-09,
"litellm_provider": "deepseek",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"max_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 2.8e-07,
"source": "https://api-docs.deepseek.com/quick_start/pricing",
"supported_endpoints": [
"/v1/chat/completions"
],
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true
},
"deepseek/deepseek-v4-pro": {
"cache_creation_input_token_cost": 0.0,
"cache_read_input_token_cost": 1.45e-08,
"input_cost_per_token": 1.74e-06,
"input_cost_per_token_cache_hit": 1.45e-08,
"litellm_provider": "deepseek",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"max_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 3.48e-06,
"source": "https://api-docs.deepseek.com/quick_start/pricing",
"supported_endpoints": [
"/v1/chat/completions"
],
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true
},
"deepseek.v3-v1:0": {
"input_cost_per_token": 5.8e-07,
"litellm_provider": "bedrock_converse",

View file

@ -12933,6 +12933,56 @@
"supports_reasoning": true,
"supports_tool_choice": true
},
"deepseek/deepseek-v4-flash": {
"cache_creation_input_token_cost": 0.0,
"cache_read_input_token_cost": 2.8e-09,
"input_cost_per_token": 1.4e-07,
"input_cost_per_token_cache_hit": 2.8e-09,
"litellm_provider": "deepseek",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"max_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 2.8e-07,
"source": "https://api-docs.deepseek.com/quick_start/pricing",
"supported_endpoints": [
"/v1/chat/completions"
],
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true
},
"deepseek/deepseek-v4-pro": {
"cache_creation_input_token_cost": 0.0,
"cache_read_input_token_cost": 1.45e-08,
"input_cost_per_token": 1.74e-06,
"input_cost_per_token_cache_hit": 1.45e-08,
"litellm_provider": "deepseek",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"max_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 3.48e-06,
"source": "https://api-docs.deepseek.com/quick_start/pricing",
"supported_endpoints": [
"/v1/chat/completions"
],
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true
},
"deepseek.v3-v1:0": {
"input_cost_per_token": 5.8e-07,
"litellm_provider": "bedrock_converse",

View file

@ -0,0 +1,64 @@
import json
from pathlib import Path
import pytest
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
@pytest.mark.parametrize(
"model,input_cost,output_cost,cache_hit_cost",
[
("deepseek/deepseek-v4-flash", 1.4e-07, 2.8e-07, 2.8e-09),
("deepseek/deepseek-v4-pro", 1.74e-06, 3.48e-06, 1.45e-08),
],
)
def test_deepseek_v4_model_info(model, input_cost, output_cost, cache_hit_cost):
json_path = Path(__file__).parents[2] / "model_prices_and_context_window.json"
with open(json_path) as f:
model_cost = json.load(f)
info = model_cost.get(model)
assert (
info is not None
), f"{model} not found in model_prices_and_context_window.json"
assert info["litellm_provider"] == "deepseek"
assert info["mode"] == "chat"
assert info["input_cost_per_token"] == input_cost
assert info["output_cost_per_token"] == output_cost
assert info["input_cost_per_token_cache_hit"] == cache_hit_cost
assert info["cache_read_input_token_cost"] == cache_hit_cost
assert info["max_input_tokens"] == 1048576
assert info["max_output_tokens"] == 393216
assert info["max_tokens"] == 393216
assert info["supports_function_calling"] is True
assert info["supports_prompt_caching"] is True
assert info["supports_reasoning"] is True
assert info["supports_response_schema"] is True
assert info["supports_tool_choice"] is True
assert info["supports_system_messages"] is True
routed_model, provider, _, _ = get_llm_provider(model=model)
assert routed_model == model.split("/", 1)[1]
assert provider == "deepseek"
def test_deepseek_v4_backup_matches_main():
"""Ensure the bundled model cost map stays in sync with the canonical file."""
repo_root = Path(__file__).parents[2]
main_path = repo_root / "model_prices_and_context_window.json"
backup_path = repo_root / "litellm" / "model_prices_and_context_window_backup.json"
with open(main_path) as f:
main_cost = json.load(f)
with open(backup_path) as f:
backup_cost = json.load(f)
for model in ("deepseek/deepseek-v4-flash", "deepseek/deepseek-v4-pro"):
assert backup_cost.get(model) == main_cost.get(
model
), f"{model} differs between main and backup model cost maps"