Merge pull request #26721 from BerriAI/litellm_fix-deprecated-bedrock-model

fix(tests): replace deprecated Bedrock Claude 3.7 Sonnet model ID
This commit is contained in:
yuneng-jiang 2026-04-28 16:23:21 -07:00 committed by GitHub
commit 89f0d4024e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 58 additions and 58 deletions

View file

@ -314,11 +314,11 @@ def test_update_litellm_params_for_health_check():
# Issue #15807: Fixes health checks sending "region/model" as model ID to AWS
model_info = {}
litellm_params = {
"model": "bedrock/us-gov-west-1/anthropic.claude-3-7-sonnet-20250219-v1:0",
"model": "bedrock/us-gov-west-1/anthropic.claude-sonnet-4-5-20250929-v1:0",
"api_key": "fake_key",
}
updated_params = _update_litellm_params_for_health_check(model_info, litellm_params)
assert updated_params["model"] == "anthropic.claude-3-7-sonnet-20250219-v1:0"
assert updated_params["model"] == "anthropic.claude-sonnet-4-5-20250929-v1:0"
# Test with Bedrock cross-region inference profile - should preserve the inference profile prefix
# AWS requires inference profile IDs like "us.anthropic.claude..." for cross-region routing

View file

@ -2309,11 +2309,11 @@ def test_get_provider_audio_transcription_config():
@pytest.mark.parametrize(
"model, expected_bool",
[
("anthropic.claude-3-7-sonnet-20250219-v1:0", True),
("us.anthropic.claude-3-7-sonnet-20250219-v1:0", True),
("anthropic.claude-sonnet-4-5-20250929-v1:0", True),
("us.anthropic.claude-sonnet-4-5-20250929-v1:0", True),
],
)
def test_claude_3_7_sonnet_supports_pdf_input(model, expected_bool):
def test_claude_sonnet_4_5_supports_pdf_input(model, expected_bool):
from litellm.utils import supports_pdf_input
assert supports_pdf_input(model) == expected_bool

View file

@ -134,7 +134,7 @@ class TestBedrockAnthropicPromptCachingRegression:
if "converse" in model_prefix:
config = AmazonConverseConfig()
result = config.transform_request(
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=messages,
optional_params={},
litellm_params={},
@ -162,7 +162,7 @@ class TestBedrockAnthropicPromptCachingRegression:
else:
config = AmazonAnthropicClaudeConfig()
result = config.transform_request(
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=messages,
optional_params={},
litellm_params={},
@ -227,7 +227,7 @@ class TestBedrockAnthropicPromptCachingRegression:
if "converse" in model_prefix:
config = AmazonConverseConfig()
result = config._transform_request_helper(
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
system_content_blocks=[],
optional_params={},
messages=messages,
@ -236,7 +236,7 @@ class TestBedrockAnthropicPromptCachingRegression:
else:
config = AmazonAnthropicClaudeConfig()
result = config.transform_request(
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=messages,
optional_params={},
litellm_params={},
@ -498,7 +498,7 @@ class TestBedrockAnthropicCombinedRegressions:
if "converse" in model_prefix:
config = AmazonConverseConfig()
result = config._transform_request_helper(
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
system_content_blocks=[],
optional_params={},
messages=messages,
@ -518,7 +518,7 @@ class TestBedrockAnthropicCombinedRegressions:
else:
config = AmazonAnthropicClaudeConfig()
result = config.transform_request(
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=messages,
optional_params={},
litellm_params={},

View file

@ -1323,7 +1323,7 @@ def test_base_aws_llm_get_credentials():
def test_bedrock_completion_test_2():
litellm.set_verbose = True
data = {
"model": "bedrock/anthropic.claude-3-7-sonnet-20250219-v1:0",
"model": "bedrock/anthropic.claude-sonnet-4-5-20250929-v1:0",
"messages": [
{
"role": "system",
@ -1630,7 +1630,7 @@ def test_bedrock_completion_test_4(modify_params):
litellm.modify_params = modify_params
data = {
"model": "anthropic.claude-3-7-sonnet-20250219-v1:0",
"model": "anthropic.claude-sonnet-4-5-20250929-v1:0",
"messages": [
{
"role": "user",
@ -2115,7 +2115,7 @@ class TestBedrockConverseAnthropicUnitTests(BaseAnthropicChatTest):
def get_base_completion_call_args_with_thinking(self) -> dict:
return {
"model": "bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
"thinking": {"type": "enabled", "budget_tokens": 16000},
}
@ -2828,7 +2828,7 @@ async def test_bedrock_thinking_in_assistant_message(sync_mode):
client = AsyncHTTPHandler()
params = {
"model": "bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
"messages": [
{
"role": "assistant",
@ -2887,7 +2887,7 @@ async def test_bedrock_stream_thinking_content_openwebui():
```
"""
response = await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=[{"role": "user", "content": "Hello who is this?"}],
stream=True,
max_tokens=1080,

View file

@ -580,7 +580,7 @@ def test_litellm_gateway_from_sdk_with_response_cost_in_additional_headers():
def test_litellm_gateway_from_sdk_with_thinking_param():
try:
response = litellm.completion(
model="litellm_proxy/anthropic.claude-3-7-sonnet-20250219-v1:0",
model="litellm_proxy/anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=[{"role": "user", "content": "Hello world"}],
api_base="http://0.0.0.0:4000",
api_key="sk-PIp1h0RekR",

View file

@ -1828,7 +1828,7 @@ def test_azure_response_format_param():
"model, provider",
[
("claude-3-7-sonnet-20240620-v1:0", "anthropic"),
("anthropic.claude-3-7-sonnet-20250219-v1:0", "bedrock"),
("anthropic.claude-sonnet-4-5-20250929-v1:0", "bedrock"),
("invoke/anthropic.claude-3-7-sonnet-20240620-v1:0", "bedrock"),
("claude-3-7-sonnet@20250219", "vertex_ai"),
],

View file

@ -159,7 +159,7 @@ def test_aaparallel_function_call(model):
"model",
[
"anthropic/claude-4-sonnet-20250514",
"bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
],
)
@pytest.mark.flaky(retries=3, delay=1)

View file

@ -96,8 +96,8 @@ class BaseAnthropicMessagesPromptCachingTest(ABC):
Returns the model string to use for tests.
Examples:
- "bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0"
- "bedrock/invoke/anthropic.claude-3-7-sonnet-20250219-v1:0"
- "bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0"
- "bedrock/invoke/anthropic.claude-sonnet-4-5-20250929-v1:0"
"""
pass

View file

@ -31,7 +31,7 @@ class TestBedrockConversePromptCaching(BaseAnthropicMessagesPromptCachingTest):
"""
def get_model(self) -> str:
return "bedrock/converse/us.anthropic.claude-3-7-sonnet-20250219-v1:0"
return "bedrock/converse/us.anthropic.claude-sonnet-4-5-20250929-v1:0"
class TestBedrockInvokePromptCaching(BaseAnthropicMessagesPromptCachingTest):
@ -43,4 +43,4 @@ class TestBedrockInvokePromptCaching(BaseAnthropicMessagesPromptCachingTest):
"""
def get_model(self) -> str:
return "bedrock/invoke/us.anthropic.claude-3-7-sonnet-20250219-v1:0"
return "bedrock/invoke/us.anthropic.claude-sonnet-4-5-20250929-v1:0"

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"id": "chatcmpl-fa9be5b7-9487-46ab-86de-6462d578fea1", "created": 1750615148, "model": "arn:aws:bedrock:us-west-2:1234567890123:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0", "object": "chat.completion", "system_fingerprint": null, "choices": [{"finish_reason": "stop", "index": 0, "message": {"content": "The capital of France is Paris. Paris has been the capital city of France since 987 CE when Hugh Capet, the first king of the Capetian dynasty, made the city his seat of government. Today, Paris is not only the political capital but also the cultural and economic center of France.", "role": "assistant", "tool_calls": null, "function_call": null}}], "usage": {"completion_tokens": 67, "prompt_tokens": 14, "total_tokens": 81, "completion_tokens_details": null, "prompt_tokens_details": {"audio_tokens": null, "cached_tokens": 0}, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0}}
{"id": "chatcmpl-fa9be5b7-9487-46ab-86de-6462d578fea1", "created": 1750615148, "model": "arn:aws:bedrock:us-west-2:1234567890123:inference-profile/us.anthropic.claude-sonnet-4-5-20250929-v1:0", "object": "chat.completion", "system_fingerprint": null, "choices": [{"finish_reason": "stop", "index": 0, "message": {"content": "The capital of France is Paris. Paris has been the capital city of France since 987 CE when Hugh Capet, the first king of the Capetian dynasty, made the city his seat of government. Today, Paris is not only the political capital but also the cultural and economic center of France.", "role": "assistant", "tool_calls": null, "function_call": null}}], "usage": {"completion_tokens": 67, "prompt_tokens": 14, "total_tokens": 81, "completion_tokens_details": null, "prompt_tokens_details": {"audio_tokens": null, "cached_tokens": 0}, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 0}}

View file

@ -220,7 +220,7 @@ async def test_anthropic_cache_control_hook_negative_indices():
with patch.object(client, "post", return_value=mock_response) as mock_post:
# Test with multiple messages and negative indices
response = await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=[
{
"role": "system",
@ -352,7 +352,7 @@ async def test_anthropic_cache_control_hook_out_of_bounds_logging():
]
await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=messages,
cache_control_injection_points=[
{"location": "message", "index": 10}
@ -420,7 +420,7 @@ async def test_anthropic_cache_control_hook_negative_out_of_bounds_logging():
]
await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=messages,
cache_control_injection_points=[
{
@ -486,7 +486,7 @@ async def test_anthropic_cache_control_hook_multiple_user_messages():
with patch.object(client, "post", return_value=mock_response) as mock_post:
# Test with multiple user messages and negative indices
response = await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=[
{
"role": "user",
@ -586,7 +586,7 @@ async def test_anthropic_cache_control_hook_out_of_bounds(bad_index):
]
await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=messages,
cache_control_injection_points=[
{"location": "message", "index": bad_index}
@ -651,7 +651,7 @@ async def test_anthropic_cache_control_hook_single_message(message_list):
client = AsyncHTTPHandler()
with patch.object(client, "post", return_value=mock_response) as mock_post:
await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=message_list,
cache_control_injection_points=[{"location": "message", "index": -1}],
client=client,
@ -691,7 +691,7 @@ async def test_anthropic_cache_control_hook_empty_message_list():
match="bedrock requires at least one non-system message",
):
await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=[],
cache_control_injection_points=[
{"location": "message", "index": -1}
@ -742,7 +742,7 @@ async def test_anthropic_cache_control_hook_no_op():
]
await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=messages,
# No cache_control_injection_points parameter
client=client,
@ -799,7 +799,7 @@ async def test_anthropic_cache_control_hook_multiple_content_items_last_only():
client = AsyncHTTPHandler()
with patch.object(client, "post", return_value=mock_response) as mock_post:
response = await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=[
{
"role": "user",
@ -874,7 +874,7 @@ async def test_anthropic_cache_control_hook_document_analysis_multiple_pages():
client = AsyncHTTPHandler()
with patch.object(client, "post", return_value=mock_response) as mock_post:
response = await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=[
{
"role": "user",
@ -1057,7 +1057,7 @@ async def test_anthropic_cache_control_hook_string_negative_index():
client = AsyncHTTPHandler()
with patch.object(client, "post", return_value=mock_response) as mock_post:
await litellm.acompletion(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
messages=[
{"role": "user", "content": "First message"},
{"role": "assistant", "content": "First response"},

View file

@ -262,7 +262,7 @@ class TestOpenTelemetryProviderInitialization(unittest.TestCase):
class TestOpenTelemetry(unittest.TestCase):
POLL_INTERVAL = 0.05
POLL_TIMEOUT = 2.0
MODEL = "arn:aws:bedrock:us-west-2:1234567890123:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0"
MODEL = "arn:aws:bedrock:us-west-2:1234567890123:inference-profile/us.anthropic.claude-sonnet-4-5-20250929-v1:0"
HERE = os.path.dirname(__file__)
@patch.dict(os.environ, {}, clear=True)

View file

@ -77,7 +77,7 @@ async def test_anthropic_bedrock_thinking_blocks_with_none_content():
# test _bedrock_converse_messages_pt_async
result = await BedrockConverseMessagesProcessor._bedrock_converse_messages_pt_async(
messages=messages,
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
llm_provider="bedrock",
)

View file

@ -279,7 +279,7 @@ def test_reasoning_with_forced_tool_choice_switches_to_auto():
}
optional_params = config.map_openai_params(
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
non_default_params=non_default_params,
optional_params={},
drop_params=False,
@ -2797,7 +2797,7 @@ def test_thinking_with_max_completion_tokens():
result = config.map_openai_params(
non_default_params=non_default_params_with_max_completion,
optional_params=optional_params,
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
drop_params=False,
)
@ -2819,7 +2819,7 @@ def test_thinking_with_max_completion_tokens():
result = config.map_openai_params(
non_default_params=non_default_params_with_max_tokens,
optional_params=optional_params,
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
drop_params=False,
)
@ -2842,7 +2842,7 @@ def test_thinking_with_max_completion_tokens():
result = config.map_openai_params(
non_default_params=non_default_params_without_max,
optional_params=optional_params,
model="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
model="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
drop_params=False,
)
@ -3617,7 +3617,7 @@ class TestBedrockMinThinkingBudgetTokens:
"""Test that thinking.budget_tokens is clamped to the Bedrock minimum (1024)."""
def _map_params(
self, thinking_value, model="anthropic.claude-3-7-sonnet-20250219-v1:0"
self, thinking_value, model="anthropic.claude-sonnet-4-5-20250929-v1:0"
):
"""Helper to call map_openai_params with the given thinking value."""
config = AmazonConverseConfig()
@ -3651,7 +3651,7 @@ class TestBedrockMinThinkingBudgetTokens:
result = config.map_openai_params(
non_default_params={},
optional_params={},
model="anthropic.claude-3-7-sonnet-20250219-v1:0",
model="anthropic.claude-sonnet-4-5-20250929-v1:0",
drop_params=False,
)
assert "thinking" not in result or result.get("thinking") is None

View file

@ -1179,7 +1179,7 @@ def test_get_model_info_shows_supports_computer_use():
"model, custom_llm_provider",
[
("gpt-3.5-turbo", "openai"),
("anthropic.claude-3-7-sonnet-20250219-v1:0", "bedrock"),
("anthropic.claude-sonnet-4-5-20250929-v1:0", "bedrock"),
("gemini-2.5-pro", "vertex_ai"),
],
)
@ -1325,7 +1325,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/bedrock-claude-3-opus",
"bedrock/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
),
(
@ -1623,7 +1623,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/bedrock-claude-3-opus",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
"Bedrock Claude 3 Opus via Converse API",
),
@ -1710,7 +1710,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/staging-claude-opus",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
"Staging Claude Opus",
),
@ -1722,7 +1722,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/high-performance-claude",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
"High-performance Claude deployment",
),
@ -1860,7 +1860,7 @@ class TestProxyFunctionCalling:
bedrock_models = [
"bedrock/converse/anthropic.claude-3-haiku-20240307-v1:0",
"bedrock/converse/anthropic.claude-3-sonnet-20240229-v1:0",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
]
for model in bedrock_models:
@ -1892,7 +1892,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/bedrock-claude-3-opus",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
"Bedrock Claude 3 Opus via Converse API",
),
@ -1979,7 +1979,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/staging-claude-opus",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
"Staging Claude Opus",
),
@ -1991,7 +1991,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/high-performance-claude",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
"High-performance Claude deployment",
),
@ -2129,7 +2129,7 @@ class TestProxyFunctionCalling:
bedrock_models = [
"bedrock/converse/anthropic.claude-3-haiku-20240307-v1:0",
"bedrock/converse/anthropic.claude-3-sonnet-20240229-v1:0",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
]
for model in bedrock_models:
@ -2161,7 +2161,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/bedrock-claude-3-opus",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
"Bedrock Claude 3 Opus via Converse API",
),
@ -2248,7 +2248,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/staging-claude-opus",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
"Staging Claude Opus",
),
@ -2260,7 +2260,7 @@ class TestProxyFunctionCalling:
),
(
"litellm_proxy/high-performance-claude",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
False,
"High-performance Claude deployment",
),
@ -2398,7 +2398,7 @@ class TestProxyFunctionCalling:
bedrock_models = [
"bedrock/converse/anthropic.claude-3-haiku-20240307-v1:0",
"bedrock/converse/anthropic.claude-3-sonnet-20240229-v1:0",
"bedrock/converse/anthropic.claude-3-7-sonnet-20250219-v1:0",
"bedrock/converse/anthropic.claude-sonnet-4-5-20250929-v1:0",
]
for model in bedrock_models: