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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Add support for `strict` parameter in Anthropic tool schemas (#16725)
Bradleyd0c880e5558e
diff --git a/litellm/types/llms/anthropic.py b/litellm/types/llms/anthropic.pyindex 950437744f7..94cdb2775b3 100644--- a/litellm/types/llms/anthropic.py+++ b/litellm/types/llms/anthropic.py@@ -25,6 +25,7 @@ AnthropicInputSchema = TypedDict("additionalProperties": Optional[bool],"required": Optional[List[str]],"$defs": Optional[Dict],+ "strict": Optional[bool],},total=False,)diff --git a/tests/llm_translation/test_anthropic_completion.py b/tests/llm_translation/test_anthropic_completion.pyindex 27841140e5b..accb536afb1 100644--- a/tests/llm_translation/test_anthropic_completion.py+++ b/tests/llm_translation/test_anthropic_completion.py@@ -1691,3 +1691,78 @@ def test_anthropic_via_responses_api():print(f"✓ All {len(events_seen)} events matched expected structure")print(f"✓ Received {text_delta_count} text delta chunks")++def test_anthropic_strict_parameter_passthrough():+ """Test that the strict parameter in tool parameters is passed through to Anthropic input_schema"""+ args = {+ "non_default_params": {+ "tools": [+ {+ "type": "function",+ "function": {+ "name": "get_weather",+ "description": "Get weather information",+ "parameters": {+ "type": "object",+ "properties": {+ "location": {"type": "string"},+ },+ "required": ["location"],+ "strict": True,+ },+ },+ }+ ],+ }+ }++ mapped_params = litellm.AnthropicConfig().map_openai_params(+ non_default_params=args["non_default_params"],+ optional_params={},+ model="claude-sonnet-4-5-20250929",+ drop_params=False,+ )++ # Verify the strict parameter is in the mapped tool's input_schema+ assert "tools" in mapped_params+ assert len(mapped_params["tools"]) == 1+ tool = mapped_params["tools"][0]+ assert "input_schema" in tool+ assert tool["input_schema"]["strict"] is True++def test_anthropic_strict_not_present():+ """Test that the strict parameter in tool parameters is passed through to Anthropic input_schema"""+ args = {+ "non_default_params": {+ "tools": [+ {+ "type": "function",+ "function": {+ "name": "get_weather",+ "description": "Get weather information",+ "parameters": {+ "type": "object",+ "properties": {+ "location": {"type": "string"},+ },+ "required": ["location"],+ },+ },+ }+ ],+ }+ }++ mapped_params = litellm.AnthropicConfig().map_openai_params(+ non_default_params=args["non_default_params"],+ optional_params={},+ model="claude-sonnet-4-5-20250929",+ drop_params=False,+ )++ # Verify the strict parameter does not exist if it is not passed in+ assert "tools" in mapped_params+ assert len(mapped_params["tools"]) == 1+ tool = mapped_params["tools"][0]+ assert "input_schema" in tool+ assert "strict" not in tool["input_schema"]