Skip to content

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]

fix: add supports_mid_conversation_system to bare first-party Claude cost-map keys

Shifat Islam Santo4cd1c81a2dcd
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index b288269b0a2..4c1b46f85ab 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -12106,6 +12106,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@@ -12493,6 +12494,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@@ -12528,6 +12530,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@@ -12566,6 +12569,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@@ -47684,6 +47688,7 @@
},
"source": "https://docs.claude.com/en/docs/about-claude/models/overview",
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index b288269b0a2..4c1b46f85ab 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -12106,6 +12106,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@@ -12493,6 +12494,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@@ -12528,6 +12530,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@@ -12566,6 +12569,7 @@
"search_context_size_medium": 0.01
},
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
@@ -47684,6 +47688,7 @@
},
"source": "https://docs.claude.com/en/docs/about-claude/models/overview",
"supports_adaptive_thinking": true,
+ "supports_mid_conversation_system": true,
"supports_assistant_prefill": false,
"supports_computer_use": true,
"supports_function_calling": true,
diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py
index f11324ca376..91f5023496a 100644
--- a/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py
+++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py
@@ -960,3 +960,40 @@ def test_gate_passthrough_skipped_when_only_chat_completions_supported(monkeypat
assert result == "translated"
assert translation_calls["count"] == 1
assert "config" not in captured
+
+
+def test_first_party_claude_4_8_plus_cost_map_entries_carry_mid_conversation_system_flag():
+ """Regional and provider-prefixed Claude 4.8+/5 entries carry
+ ``supports_mid_conversation_system``, but the bare first-party keys
+ (``claude-opus-4-8``) that a plain ``custom_llm_provider="anthropic"``
+ lookup resolves were missed, so that lookup reports the capability as
+ unset. Every mapped first-party entry the fallback rule matches must
+ carry the flag."""
+ import json
+ import os
+ import re
+
+ import litellm
+
+ cost_map_path = os.path.join(
+ os.path.dirname(litellm.__file__), "model_prices_and_context_window_backup.json"
+ )
+ with open(cost_map_path) as f:
+ cost_map = json.load(f)
+ rules = cost_map["fallback_generalizations"]["rules"]
+ rule_pattern = next(
+ (r["pattern"] for r in rules if r["name"] == "claude-mid-conversation-system"),
+ None,
+ )
+ assert rule_pattern is not None, "claude-mid-conversation-system rule not found in fallback_generalizations"
+ pattern = re.compile(rule_pattern, re.IGNORECASE)
+ missing = [
+ key
+ for key, info in cost_map.items()
+ if isinstance(info, dict)
+ and info.get("litellm_provider") == "anthropic"
+ and "claude" in key
+ and pattern.search(key)
+ and info.get("supports_mid_conversation_system") is not True
+ ]
+ assert missing == []