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
fix(anthropic): correct claude-3-7-sonnet max_tokens to 64K default (#17979)
Cesar Garcia4fdbbdfe6de7
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex 4b016bc6ca6..26aae425fae 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -6723,8 +6723,8 @@"input_cost_per_token": 3e-06,"litellm_provider": "anthropic","max_input_tokens": 200000,- "max_output_tokens": 128000,- "max_tokens": 128000,+ "max_output_tokens": 64000,+ "max_tokens": 64000,"mode": "chat","output_cost_per_token": 1.5e-05,"search_context_cost_per_query": {@@ -6752,8 +6752,8 @@"input_cost_per_token": 3e-06,"litellm_provider": "anthropic","max_input_tokens": 200000,- "max_output_tokens": 128000,- "max_tokens": 128000,+ "max_output_tokens": 64000,+ "max_tokens": 64000,"mode": "chat","output_cost_per_token": 1.5e-05,"search_context_cost_per_query": {diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex 4b016bc6ca6..26aae425fae 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -6723,8 +6723,8 @@"input_cost_per_token": 3e-06,"litellm_provider": "anthropic","max_input_tokens": 200000,- "max_output_tokens": 128000,- "max_tokens": 128000,+ "max_output_tokens": 64000,+ "max_tokens": 64000,"mode": "chat","output_cost_per_token": 1.5e-05,"search_context_cost_per_query": {@@ -6752,8 +6752,8 @@"input_cost_per_token": 3e-06,"litellm_provider": "anthropic","max_input_tokens": 200000,- "max_output_tokens": 128000,- "max_tokens": 128000,+ "max_output_tokens": 64000,+ "max_tokens": 64000,"mode": "chat","output_cost_per_token": 1.5e-05,"search_context_cost_per_query": {diff --git a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.pyindex ec612109d9c..9b6d1c6e178 100644--- a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py+++ b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py@@ -1651,15 +1651,16 @@ def test_get_max_tokens_for_model_claude_35():def test_get_max_tokens_for_model_claude_37():"""Test that get_max_tokens_for_model returns correct value for Claude 3.7 models.- Claude 3.7 Sonnet has max_output_tokens of 128000 (128K with extended thinking).+ Claude 3.7 Sonnet has max_output_tokens of 64000 by default.+ 128K output requires the beta header 'output-128k-2025-02-19'.Fixes: https://github.com/BerriAI/litellm/issues/8835"""config = AnthropicConfig()- # Claude 3.7 Sonnet should return 128000 (128K)+ # Claude 3.7 Sonnet should return 64000 (64K default, 128K requires beta header)max_tokens = config.get_max_tokens_for_model("claude-3-7-sonnet-20250219")- assert max_tokens == 128000+ assert max_tokens == 64000def test_get_max_tokens_for_model_unknown():@@ -1698,9 +1699,9 @@ def test_get_config_with_model_uses_dynamic_max_tokens():config_claude35 = AnthropicConfig.get_config(model="claude-3-5-sonnet-20241022")assert config_claude35["max_tokens"] == 8192- # Claude 3.7 model should get 128000 (128K with extended thinking)+ # Claude 3.7 model should get 64000 (64K default, 128K requires beta header)config_claude37 = AnthropicConfig.get_config(model="claude-3-7-sonnet-20250219")- assert config_claude37["max_tokens"] == 128000+ assert config_claude37["max_tokens"] == 64000def test_get_config_without_model_uses_fallback():