Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(model-info): sync DeepSeek model metadata and add bare-name fallback (#20885)

skylarkoo7737f12f0c6ad
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index 9b5a7b42d0e..f6edcf7efd0 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -10756,14 +10756,22 @@
"input_cost_per_token": 2.8e-07,
"input_cost_per_token_cache_hit": 2.8e-08,
"litellm_provider": "deepseek",
- "max_input_tokens": 128000,
+ "max_input_tokens": 131072,
"max_output_tokens": 8192,
"max_tokens": 8192,
"mode": "chat",
"output_cost_per_token": 4.2e-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_response_schema": true,
+ "supports_system_messages": true,
"supports_tool_choice": true
},
"deepseek/deepseek-coder": {
@@ -10800,16 +10808,24 @@
"input_cost_per_token": 2.8e-07,
"input_cost_per_token_cache_hit": 2.8e-08,
"litellm_provider": "deepseek",
- "max_input_tokens": 128000,
- "max_output_tokens": 8192,
- "max_tokens": 8192,
+ "max_input_tokens": 131072,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
"mode": "chat",
"output_cost_per_token": 4.2e-07,
+ "source": "https://api-docs.deepseek.com/quick_start/pricing",
+ "supported_endpoints": [
+ "/v1/chat/completions"
+ ],
"supports_assistant_prefill": true,
- "supports_function_calling": true,
+ "supports_function_calling": false,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": false,
"supports_prompt_caching": true,
"supports_reasoning": true,
- "supports_tool_choice": true
+ "supports_response_schema": true,
+ "supports_system_messages": true,
+ "supports_tool_choice": false
},
"deepseek/deepseek-v3": {
"cache_creation_input_token_cost": 0.0,
diff --git a/litellm/proxy/policy_engine/policy_resolve_endpoints.py b/litellm/proxy/policy_engine/policy_resolve_endpoints.py
index a81d4405678..eb4d3fc5845 100644
--- a/litellm/proxy/policy_engine/policy_resolve_endpoints.py
+++ b/litellm/proxy/policy_engine/policy_resolve_endpoints.py
@@ -12,7 +12,6 @@ from fastapi import APIRouter, Depends, HTTPException, Query
from litellm._logging import verbose_proxy_logger
from litellm.constants import MAX_POLICY_ESTIMATE_IMPACT_ROWS
from litellm.proxy._types import UserAPIKeyAuth
-from litellm.proxy.auth.route_checks import RouteChecks
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
from litellm.proxy.policy_engine.attachment_registry import get_attachment_registry
from litellm.proxy.policy_engine.policy_registry import get_policy_registry
diff --git a/litellm/utils.py b/litellm/utils.py
index ed0d6ee930d..291969cc5d4 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -2506,6 +2506,16 @@ def _supports_factory(model: str, custom_llm_provider: Optional[str], key: str)
if model_info.get(key, False) is True:
return True
elif model_info.get(key) is None: # don't check if 'False' explicitly set
+ # Fallback: when the provider-prefixed entry (e.g.
+ # "deepseek/deepseek-chat") exists but is missing a capability
+ # field, check the bare model-name entry (e.g. "deepseek-chat")
+ # which may carry the complete metadata. See #20885.
+ bare_model_key = _get_model_cost_key(model)
+ if bare_model_key is not None:
+ bare_entry = litellm.model_cost.get(bare_model_key) or {}
+ if bare_entry.get(key, False) is True:
+ return True
+
supported_by_provider = _supports_provider_info_factory(
model, custom_llm_provider, key
)
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index 9b5a7b42d0e..f6edcf7efd0 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -10756,14 +10756,22 @@
"input_cost_per_token": 2.8e-07,
"input_cost_per_token_cache_hit": 2.8e-08,
"litellm_provider": "deepseek",
- "max_input_tokens": 128000,
+ "max_input_tokens": 131072,
"max_output_tokens": 8192,
"max_tokens": 8192,
"mode": "chat",
"output_cost_per_token": 4.2e-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_response_schema": true,
+ "supports_system_messages": true,
"supports_tool_choice": true
},
"deepseek/deepseek-coder": {
@@ -10800,16 +10808,24 @@
"input_cost_per_token": 2.8e-07,
"input_cost_per_token_cache_hit": 2.8e-08,
"litellm_provider": "deepseek",
- "max_input_tokens": 128000,
- "max_output_tokens": 8192,
- "max_tokens": 8192,
+ "max_input_tokens": 131072,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
"mode": "chat",
"output_cost_per_token": 4.2e-07,
+ "source": "https://api-docs.deepseek.com/quick_start/pricing",
+ "supported_endpoints": [
+ "/v1/chat/completions"
+ ],
"supports_assistant_prefill": true,
- "supports_function_calling": true,
+ "supports_function_calling": false,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": false,
"supports_prompt_caching": true,
"supports_reasoning": true,
- "supports_tool_choice": true
+ "supports_response_schema": true,
+ "supports_system_messages": true,
+ "supports_tool_choice": false
},
"deepseek/deepseek-v3": {
"cache_creation_input_token_cost": 0.0,
diff --git a/tests/test_litellm/test_deepseek_model_metadata.py b/tests/test_litellm/test_deepseek_model_metadata.py
new file mode 100644
index 00000000000..4900af5d97d
--- /dev/null
+++ b/tests/test_litellm/test_deepseek_model_metadata.py
@@ -0,0 +1,180 @@
+"""
+Regression tests for #20885 – ``supports_response_schema`` (and related
+capability flags) must be consistent between the bare model-name entry
+(e.g. ``deepseek-chat``) and the provider-prefixed entry
+(e.g. ``deepseek/deepseek-chat``) in the model-cost map.
+
+The bug caused ``supports_response_schema("deepseek/deepseek-chat")`` to
+return ``False`` even though the canonical ``deepseek-chat`` entry has the
+field set to ``True``.
+"""
+
+import json
+import os
+import sys
+
+sys.path.insert(
+ 0, os.path.abspath("../..")
+) # Adds the parent directory to the system path
+
+import litellm
+from litellm.utils import (
+ _supports_factory,
+ supports_response_schema,
+)
+
+
+# ---------------------------------------------------------------------------
+# Data-level tests – verify the JSON files are in sync
+# ---------------------------------------------------------------------------
+
+
+def _load_backup_json() -> dict:
+ """Load the backup JSON directly from disk."""
+ backup_path = os.path.join(
+ os.path.dirname(litellm.__file__),
+ "model_prices_and_context_window_backup.json",
+ )
+ with open(backup_path, encoding="utf-8") as f:
+ return json.load(f)
+
+
+class TestDeepSeekModelCostEntries:
+ """Verify that provider-prefixed DeepSeek entries contain the same
+ capability flags as their bare-name counterparts in the JSON files."""
+
+ def test_deepseek_chat_supports_response_schema_in_backup(self):
+ data = _load_backup_json()
+ entry = data.get("deepseek/deepseek-chat", {})
+ assert entry.get("supports_response_schema") is True
+
+ def test_deepseek_reasoner_supports_response_schema_in_backup(self):
+ data = _load_backup_json()
+ entry = data.get("deepseek/deepseek-reasoner", {})
+ assert entry.get("supports_response_schema") is True
+
+ def test_deepseek_chat_supports_system_messages_in_backup(self):
+ data = _load_backup_json()
+ entry = data.get("deepseek/deepseek-chat", {})
+ assert entry.get("supports_system_messages") is True
+
+ def test_deepseek_reasoner_supports_system_messages_in_backup(self):
+ data = _load_backup_json()
+ entry = data.get("deepseek/deepseek-reasoner", {})
+ assert entry.get("supports_system_messages") is True
+
+ def test_deepseek_chat_max_input_tokens_matches_bare_in_backup(self):
+ data = _load_backup_json()
+ bare = data.get("deepseek-chat", {})
+ prefixed = data.get("deepseek/deepseek-chat", {})
+ assert prefixed.get("max_input_tokens") == bare.get("max_input_tokens")
+
+ def test_deepseek_reasoner_max_output_tokens_matches_bare_in_backup(self):
+ data = _load_backup_json()
+ bare = data.get("deepseek-reasoner", {})
+ prefixed = data.get("deepseek/deepseek-reasoner", {})
+ assert prefixed.get("max_output_tokens") == bare.get("max_output_tokens")
+
+ def test_main_json_deepseek_chat_supports_response_schema(self):
+ main_path = os.path.join(
+ os.path.dirname(os.path.dirname(litellm.__file__)),
+ "model_prices_and_context_window.json",
+ )
+ with open(main_path, encoding="utf-8") as f:
+ data = json.load(f)
+ entry = data.get("deepseek/deepseek-chat", {})
+ assert entry.get("supports_response_schema") is True
+
+ def test_main_json_deepseek_reasoner_supports_response_schema(self):
+ main_path = os.path.join(
+ os.path.dirname(os.path.dirname(litellm.__file__)),
+ "model_prices_and_context_window.json",
+ )
+ with open(main_path, encoding="utf-8") as f:
+ data = json.load(f)
+ entry = data.get("deepseek/deepseek-reasoner", {})
+ assert entry.get("supports_response_schema") is True
+
+
+# ---------------------------------------------------------------------------
+# API-level tests – verify supports_response_schema returns True
+# ---------------------------------------------------------------------------
+
+
+class TestSupportsResponseSchemaDeepSeek:
+ """All calling conventions for DeepSeek should return True for
+ ``supports_response_schema``."""
+
+ def test_provider_slash_model(self):
+ assert supports_response_schema(model="deepseek/deepseek-chat") is True
+
+ def test_explicit_provider(self):
+ assert (
+ supports_response_schema(
+ model="deepseek-chat", custom_llm_provider="deepseek"
+ )
+ is True
+ )
+
+ def test_reasoner_provider_slash_model(self):
+ assert supports_response_schema(model="deepseek/deepseek-reasoner") is True
+
+ def test_reasoner_explicit_provider(self):
+ assert (
+ supports_response_schema(
+ model="deepseek-reasoner", custom_llm_provider="deepseek"
+ )
+ is True
+ )
+
+
+# ---------------------------------------------------------------------------
+# Fallback-logic test – bare model entry used when prefixed is incomplete
+# ---------------------------------------------------------------------------
+
+
+class TestBareModelFallback:
+ """When a provider-prefixed entry is missing a capability flag, the
+ ``_supports_factory`` fallback should consult the bare model-name
+ entry in ``litellm.model_cost``."""
+
+ def test_fallback_uses_bare_entry(self):
+ """Temporarily remove ``supports_response_schema`` from the prefixed
+ entry and verify the fallback still returns True."""
+ key = "deepseek/deepseek-chat"
+ original = litellm.model_cost.get(key, {}).get("supports_response_schema")
+ try:
+ # Simulate the pre-fix state: field missing from prefixed entry
+ if key in litellm.model_cost:
+ litellm.model_cost[key].pop("supports_response_schema", None)
+ result = _supports_factory(
+ model="deepseek-chat",
+ custom_llm_provider="deepseek",
+ key="supports_response_schema",
+ )
+ assert result is True
+ finally:
+ # Restore
+ if key in litellm.model_cost and original is not None:
+ litellm.model_cost[key]["supports_response_schema"] = original
+
+ def test_no_fallback_when_explicitly_false(self):
+ """If the prefixed entry explicitly sets a capability to ``False``,
+ the fallback must NOT override it."""
+ key = "deepseek/deepseek-reasoner"
+ # After the data fix, deepseek/deepseek-reasoner has
+ # supports_function_calling=false (matching the bare entry).
+ # Explicitly set it to False to test the guard.
+ original = litellm.model_cost.get(key, {}).get("supports_function_calling")
+ try:
+ if key in litellm.model_cost:
+ litellm.model_cost[key]["supports_function_calling"] = False
+ result = _supports_factory(
+ model="deepseek-reasoner",
+ custom_llm_provider="deepseek",
+ key="supports_function_calling",
+ )
+ assert result is False
+ finally:
+ if key in litellm.model_cost and original is not None:
+ litellm.model_cost[key]["supports_function_calling"] = original