diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py index 5041f359c0d..af868051f4d 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py @@ -767,9 +767,11 @@ class LiteLLMAnthropicMessagesAdapter: These ARNs contain neither "anthropic" nor "claude", so is_anthropic_claude_model cannot identify them even though, on the /v1/messages endpoint, they point at Claude. + Match ":bedrock:" in the ARN service field so another service's ARN that merely names + bedrock in a resource (arn:aws:sagemaker:.../my-bedrock-endpoint) is not matched. """ model_lower = model.lower() - return "arn:" in model_lower and "bedrock" in model_lower + return "arn:" in model_lower and ":bedrock:" in model_lower @staticmethod def translate_thinking_for_model( diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py index fcf0847a9db..76aa3a9c6aa 100644 --- a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py +++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py @@ -1427,11 +1427,12 @@ def test_cache_control_not_preserved_for_non_claude_model(): ), ("bedrock/amazon.titan-text-express-v1", False), ("arn:aws:sagemaker:us-east-1:123:endpoint/my-endpoint", False), + ("arn:aws:sagemaker:us-east-1:123:endpoint/my-bedrock-transcriber", False), (CACHE_CONTROL_NON_ANTHROPIC_MODEL, False), ], ) def test_is_bedrock_arn_model(model, expected): - """is_bedrock_arn_model requires both an ARN and the bedrock service in the string.""" + """is_bedrock_arn_model requires an ARN with bedrock in the service field, not just anywhere.""" assert LiteLLMAnthropicMessagesAdapter.is_bedrock_arn_model(model) is expected