Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions tests/test_litellm/llms/azure_ai/test_cost_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,21 @@ def test_flat_cost_integration_with_completion_cost(self):

def test_additional_costs_in_cost_breakdown(self):
"""Test that Azure Model Router flat cost appears in additional_costs dict."""
from datetime import datetime
from litellm.cost_calculator import completion_cost
from litellm.litellm_core_utils.litellm_logging import LitellmLoggingObject
from litellm.litellm_core_utils.litellm_logging import Logging
from litellm.types.utils import Choices, Message, ModelResponse, Usage

# Create logging object
logging_obj = LitellmLoggingObject()
# Create logging object with required parameters
logging_obj = Logging(
model="azure-model-router",
messages=[{"role": "user", "content": "Hello"}],
stream=False,
call_type="completion",
start_time=datetime.now(),
litellm_call_id="test-123",
function_id="test-function"
)

# Create a mock response for azure_ai model router
response = ModelResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ def test_advanced_tool_use_header_translation_for_opus_4_5():

def test_advanced_tool_use_header_filtered_for_non_opus_4_5():
"""
Test that advanced-tool-use-2025-11-20 header is filtered out for non-Opus 4.5 models
without adding Bedrock-specific headers.
Test that advanced-tool-use-2025-11-20 header is filtered out for models that
don't support tool search on Bedrock, without adding Bedrock-specific headers.

The translation to tool-search-tool-2025-10-19 and tool-examples-2025-10-29 should
only happen for Claude Opus 4.5.
only happen for Claude Opus 4.5 and Sonnet 4.5 (models that support tool search on Bedrock).
"""
from litellm.llms.bedrock.messages.invoke_transformations.anthropic_claude3_transformation import (
AmazonAnthropicClaudeMessagesConfig,
Expand All @@ -360,9 +360,10 @@ def test_advanced_tool_use_header_filtered_for_non_opus_4_5():
"anthropic-beta": "advanced-tool-use-2025-11-20"
}

# Test with Claude Sonnet 4.5 (not Opus 4.5)
# Test with Claude 3.5 Sonnet (which does NOT support tool search on Bedrock)
# Note: Only Claude Opus 4.5 and Sonnet 4.5 support tool search on Bedrock
result = config.transform_anthropic_messages_request(
model="anthropic.claude-sonnet-4-5-20250929-v1:0",
model="anthropic.claude-3-5-sonnet-20241022-v2:0",
messages=messages,
anthropic_messages_optional_request_params=anthropic_messages_optional_request_params,
litellm_params={},
Expand All @@ -374,11 +375,11 @@ def test_advanced_tool_use_header_filtered_for_non_opus_4_5():
assert "advanced-tool-use-2025-11-20" not in beta_headers, \
"advanced-tool-use header should be removed for Bedrock"

# Verify Bedrock-specific headers were NOT added (only for Opus 4.5)
# Verify Bedrock-specific headers were NOT added (only for Opus 4.5 and Sonnet 4.5)
assert "tool-search-tool-2025-10-19" not in beta_headers, \
"tool-search-tool should not be added for non-Opus 4.5 models"
"tool-search-tool should not be added for models that don't support tool search"
assert "tool-examples-2025-10-29" not in beta_headers, \
"tool-examples should not be added for non-Opus 4.5 models"
"tool-examples should not be added for models that don't support tool search"


def test_advanced_tool_use_header_translation_with_multiple_beta_headers():
Expand Down
Loading