Skip to main content

How to Make Claude Follow a Tool's Input Schema with strict: true

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

Your tool code expects its input in a certain shape: a number where it says number, one of a few allowed words, every required field. Without help, Claude usually gets that right, but not always. "strict": True on a tool definition makes it always right. This guide books a café table with a strict tool, with real output from anthropic 2.14.0.

Syntax​

Syntax
tool = {
"name": "<tool name>",
"description": "<what it does and when to use it>",
"strict": True,
"input_schema": {
"type": "object",
"properties": {"<argument>": {"type": "<type>"}},
"required": ["<argument>"],
"additionalProperties": False,
},
}
PartWhat it means
"strict": TrueClaude's input for this tool must match input_schema
"additionalProperties": FalseNo properties beyond the ones listed. Strict mode requires it on every object

Anthropic's strict tool use page: "Setting strict: true on a tool definition guarantees Claude's tool inputs match your JSON Schema by constraining the model's token sampling to schema-valid outputs". Its example: "Without strict mode, Claude might provide passengers: "two" or passengers: "2". With strict: true, the response always contains passengers: 2."

What It Costs​

The Claude API is paid: Claude Opus 5.5 costs $4 per million input tokens and $20 per million output tokens. Strict mode has no price of its own. The run below used 488 input and 71 output tokens, about $0.003.

Prerequisites​

  • A Claude API key, in a .env file as ANTHROPIC_API_KEY=....
  • The Anthropic Python SDK in a uv project. This guide uses anthropic 2.14.0, added with uv add anthropic, on Python 3.15.2.

Step 1: Define a Strict Tool​

Create strict_tool.py. The tool books a table: it needs a day of the week and a number of people.

strict_tool.py
import anthropic

client = anthropic.Anthropic()

DAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

book_table_tool = {
"name": "book_table",
"description": (
"Book a table at the café for one day of the week. "
"Use it whenever someone asks to reserve a table."
),
"strict": True,
"input_schema": {
"type": "object",
"properties": {
"day": {"type": "string", "enum": DAYS},
"people": {"type": "integer", "description": "How many people the table is for."},
},
"required": ["day", "people"],
"additionalProperties": False,
},
}
  • "enum": DAYS allows only the seven day names, spelled exactly like that.
  • "type": "integer" asks for a whole number, not text.
  • "strict": True turns those rules into a guarantee, and "additionalProperties": False closes the object to any other property.

Step 2: Ask for a Booking​

Add the request. The question writes the number as a word, "four":

strict_tool.py
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
tools=[book_table_tool],
messages=[{"role": "user", "content": "Please book a table for four of us on Saturday."}],
)

for block in response.content:
if block.type == "tool_use":
print("Tool call:", block.name, block.input)
print("people is a", type(block.input["people"]).__name__)

type(...).__name__ prints the Python type of the people value Claude sent.

The complete script:

strict_tool.py
import anthropic

client = anthropic.Anthropic()

DAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

book_table_tool = {
"name": "book_table",
"description": (
"Book a table at the café for one day of the week. "
"Use it whenever someone asks to reserve a table."
),
"strict": True,
"input_schema": {
"type": "object",
"properties": {
"day": {"type": "string", "enum": DAYS},
"people": {"type": "integer", "description": "How many people the table is for."},
},
"required": ["day", "people"],
"additionalProperties": False,
},
}

response = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
tools=[book_table_tool],
messages=[{"role": "user", "content": "Please book a table for four of us on Saturday."}],
)

for block in response.content:
if block.type == "tool_use":
print("Tool call:", block.name, block.input)
print("people is a", type(block.input["people"]).__name__)

The complete strict_tool.py script in a macOS-style code window: a book_table tool with strict set to True, an input schema with a day enum of the seven weekdays, an integer people property, both required, and additionalProperties False, sent with a request to book a table for four on Saturday.

Step 3: Run It​

Terminal
uv run --env-file .env strict_tool.py
Output
Tool call: book_table {'day': 'Saturday', 'people': 4}
people is a int

The output in a terminal: the tool call is book_table with day Saturday and people 4, and people is an int.

"four" arrived as the integer 4, and the day as Saturday, one of the allowed values. Your booking code can use both as they are.

Common Mistakes​

MistakeWhat happensDo this instead
"strict": True without "additionalProperties": False400: tools.0.custom: For 'object' type, 'additionalProperties' must be explicitly set to falseAdd "additionalProperties": False to every object in the schema
A number range such as "minimum": 1 in a strict schema400: tools.0.custom: For 'integer' type, property 'minimum' is not supportedLeave the range out of the schema and check it in your tool code
Expecting strict mode to make Claude call the toolIt doesn't: it only shapes the input when Claude calls the toolSay in the description when to use the tool

Troubleshooting​

SymptomLikely causeFix
A 400 that names a schema keyword as "not supported"Strict mode supports only part of JSON SchemaCheck the keyword against Anthropic's JSON Schema limitations
For 'object' type, 'additionalProperties' must be explicitly set to falseAn object in the schema is missing "additionalProperties": FalseAdd it to that object

FAQ​

Which schema features does strict mode support?​

Anthropic's JSON Schema limitations list them. Among them: all basic types, enum, required, and formats such as date and email. Not supported: number limits such as minimum and maximum, and string lengths such as minLength. Its rule: "If you use an unsupported feature, you'll receive a 400 error with details."

Is the first request slower?​

It can be. Anthropic's structured outputs page explains that a new schema is compiled once, then reused from a 24-hour cache.

Can I use strict mode on every tool?​

Yes, as long as each schema stays within the supported features. Strict mode is set per tool, on its definition.

Conclusion​

With "strict": True and "additionalProperties": False, Claude's input for book_table matched the schema: "four" became the integer 4, and the day was one of the seven allowed names.

Additional Resources​