From ce69aa17ccabcbf5be977163926b74ce0fefdfa0 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 1 Jul 2026 15:00:14 +0000 Subject: [PATCH] fix(model-map): add supports_output_config to claude-sonnet-4-5 and claude-opus-4-1 entries The model cost map entries for claude-sonnet-4-5, claude-sonnet-4-5-20250929, claude-opus-4-1, and claude-opus-4-1-20250805 were missing the supports_output_config flag. This caused response_format routing to fall through to tool-call emulation instead of the native output_format path after switching from the hardcoded substring set to the capability flag lookup. Also adds local_model_cost_map fixture to structured output tests so they use the local model map data rather than the remote main branch URL, which may not have the latest flags. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/model_prices_and_context_window_backup.json | 4 ++++ model_prices_and_context_window.json | 4 ++++ .../anthropic/chat/test_anthropic_chat_transformation.py | 8 ++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index b16e1015255..c00ab0ddd2e 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -10438,6 +10438,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_output_config": true, "supports_tool_choice": true, "supports_vision": true }, @@ -10469,6 +10470,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_output_config": true, "supports_tool_choice": true, "supports_vision": true, "supports_web_search": true @@ -10585,6 +10587,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_output_config": true, "supports_tool_choice": true, "supports_vision": true }, @@ -10612,6 +10615,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_output_config": true, "supports_tool_choice": true, "supports_vision": true }, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 3e4c5b947a1..f33a7ff281f 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -10438,6 +10438,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_output_config": true, "supports_tool_choice": true, "supports_vision": true }, @@ -10469,6 +10470,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_output_config": true, "supports_tool_choice": true, "supports_vision": true, "supports_web_search": true @@ -10585,6 +10587,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_output_config": true, "supports_tool_choice": true, "supports_vision": true }, @@ -10612,6 +10615,7 @@ "supports_prompt_caching": true, "supports_reasoning": true, "supports_response_schema": true, + "supports_output_config": true, "supports_tool_choice": true, "supports_vision": true }, 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.py index 06fab279784..6a12d8800c5 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 @@ -919,7 +919,7 @@ def test_anthropic_chat_transform_request_includes_context_management(): assert result["context_management"] == _sample_context_management_payload() -def test_anthropic_structured_output_beta_header(): +def test_anthropic_structured_output_beta_header(local_model_cost_map): from litellm.types.utils import CallTypes from litellm.utils import return_raw_request @@ -966,7 +966,7 @@ def test_anthropic_structured_output_beta_header(): "claude-opus-4.5-20251101", ], ) -def test_opus_uses_native_structured_output(model_name): +def test_opus_uses_native_structured_output(model_name, local_model_cost_map): """ Test that Opus 4.5 and 4.6 models use native Anthropic structured outputs (output_format) rather than the tool-based workaround. @@ -1008,7 +1008,7 @@ def test_opus_uses_native_structured_output(model_name): assert optional_params.get("json_mode") is True -def test_non_structured_output_model_uses_tool_workaround(): +def test_non_structured_output_model_uses_tool_workaround(local_model_cost_map): """ Test that models NOT in the native structured output list still use the tool-based workaround for response_format. @@ -5739,7 +5739,7 @@ def test_top_k_forwarded_at_transform_on_models_that_accept_it(): assert result["top_k"] == 40 -def test_opus_4_8_uses_native_structured_output(): +def test_opus_4_8_uses_native_structured_output(local_model_cost_map): """claude-opus-4-8 has supports_output_config=true in the model map, so response_format should route to the native output_format path rather than the tool-call emulation path"""