Structured outputs: two distinct features
Constraining the response body and constraining tool parameters are separate knobs.
5 min read · Lesson 1 of 12 in this domain
There are two separate things you might want to constrain, and the exam expects you to keep them apart. One is the response body — the text Claude sends back — which you shape with output_config.format and a JSON schema. The other is tool parameters — the arguments Claude passes when calling your function — which you lock down with strict: true on the tool definition. They solve different problems and compose freely in the same request. The classic slip is putting strict inside tool_choice; tool_choice only decides which tool runs, never how its inputs are validated.
- JSON outputs —
output_config.formatwith ajson_schemaconstrains the response body. - Strict tool use —
strict: trueas a top-level field on the tool definition (besidenameandinput_schema, not insidetool_choice) guarantees tool parameters validate exactly. - The two are complementary and can be used in the same request.
- The primary benefit is a stable contract: consumers read known JSON keys directly instead of regex-parsing prose.
- The old top-level
output_formatparameter is deprecated — useoutput_config.format. - A schema must declare
additionalProperties: falseand list itsrequiredfields.
response = client.messages.create(
model="claude-opus-5", max_tokens=16000,
output_config={"format": {"type": "json_schema", "schema": {...}}},
tools=[{
"name": "search_flights",
"strict": True,
"input_schema": {
"type": "object",
"properties": {"destination": {"type": "string"}},
"required": ["destination"],
"additionalProperties": False
}
}],
messages=[...]
)
Putting strict inside tool_choice. It belongs on the tool definition.
Where does strict: true belong?
tool_choice only decides which tool runs; it carries no validation flag.
What does output_config.format constrain?
Tool parameters are constrained by strict: true on the tool definition. The two compose in one request.
Practise this domain with 20%%-weighted questions in the study app.
Open in study appSource: Claude Docs — Structured outputs · Independent study aid, not affiliated with or endorsed by Anthropic.