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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Support Deepseek 3.2 with Reasoning (#17384)
Matt Greathousef22bc0aab20e
diff --git a/litellm/llms/openrouter/chat/transformation.py b/litellm/llms/openrouter/chat/transformation.pyindex f1eafe4e294..b5610852fd2 100644--- a/litellm/llms/openrouter/chat/transformation.py+++ b/litellm/llms/openrouter/chat/transformation.py@@ -10,6 +10,7 @@ from enum import Enumfrom typing import Any, AsyncIterator, Iterator, List, Optional, Tuple, Union, castimport httpx+import litellmfrom litellm.llms.base_llm.base_model_iterator import BaseModelResponseIteratorfrom litellm.llms.base_llm.chat.transformation import BaseLLMException@@ -28,6 +29,20 @@ class CacheControlSupportedModels(str, Enum):class OpenrouterConfig(OpenAIGPTConfig):+ def get_supported_openai_params(self, model: str) -> list:+ """+ Allow reasoning parameters for models flagged as reasoning-capable.+ """+ supported_params = super().get_supported_openai_params(model=model)+ try:+ if litellm.supports_reasoning(+ model=model, custom_llm_provider="openrouter"+ ) or litellm.supports_reasoning(model=model):+ supported_params.append("reasoning_effort")+ except Exception:+ pass+ return list(dict.fromkeys(supported_params))+def map_openai_params(self,non_default_params: dict,diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex 19ed734c5f8..f82abce525f 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -9629,6 +9629,21 @@"supports_prompt_caching": true,"supports_tool_choice": true},+ "deepseek/deepseek-v3.2": {+ "input_cost_per_token": 2.8e-07,+ "input_cost_per_token_cache_hit": 2.8e-08,+ "litellm_provider": "deepseek",+ "max_input_tokens": 163840,+ "max_output_tokens": 163840,+ "max_tokens": 8192,+ "mode": "chat",+ "output_cost_per_token": 4e-07,+ "supports_assistant_prefill": true,+ "supports_function_calling": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_tool_choice": true+ },"deepseek.v3-v1:0": {"input_cost_per_token": 5.8e-07,"litellm_provider": "bedrock_converse",@@ -20565,6 +20580,21 @@"supports_reasoning": true,"supports_tool_choice": true},+ "openrouter/deepseek/deepseek-v3.2": {+ "input_cost_per_token": 2.8e-07,+ "input_cost_per_token_cache_hit": 2.8e-08,+ "litellm_provider": "openrouter",+ "max_input_tokens": 163840,+ "max_output_tokens": 163840,+ "max_tokens": 8192,+ "mode": "chat",+ "output_cost_per_token": 4e-07,+ "supports_assistant_prefill": true,+ "supports_function_calling": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_tool_choice": true+ },"openrouter/deepseek/deepseek-v3.2-exp": {"input_cost_per_token": 2e-07,"input_cost_per_token_cache_hit": 2e-08,diff --git a/tests/test_litellm/llms/openrouter/chat/test_openrouter_chat_transformation.py b/tests/test_litellm/llms/openrouter/chat/test_openrouter_chat_transformation.pyindex 64ac299fd79..d5a73b3fd12 100644--- a/tests/test_litellm/llms/openrouter/chat/test_openrouter_chat_transformation.py+++ b/tests/test_litellm/llms/openrouter/chat/test_openrouter_chat_transformation.py@@ -489,3 +489,30 @@ def test_openrouter_cost_tracking_streaming():# Verify cost field is preserved in the Usage object - this is the key data for cost tracking# The chunk_parser converts the dict to a Usage Pydantic model which includes the cost fieldassert result2.usage.cost == 0.0001+++def test_openrouter_reasoning_models_allow_reasoning_effort_param():+ """+ OpenRouter reasoning-capable models should accept the reasoning_effort param.+ """+ config = OpenrouterConfig()++ supported_params = config.get_supported_openai_params(+ model="openrouter/deepseek/deepseek-v3.2"+ )++ assert "reasoning_effort" in supported_params+ assert supported_params.count("reasoning_effort") == 1+++def test_openrouter_non_reasoning_models_do_not_add_reasoning_effort():+ """+ Models without reasoning support should not gain reasoning-specific params.+ """+ config = OpenrouterConfig()++ supported_params = config.get_supported_openai_params(+ model="openrouter/anthropic/claude-3-5-haiku"+ )++ assert "reasoning_effort" not in supported_params