AITraining2U

Programs

Resources

Case Studies

Quick Links

Enquire Now
Domain 3 · 20%% of exam

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.

Key points
  • JSON outputsoutput_config.format with a json_schema constrains the response body.
  • Strict tool usestrict: true as a top-level field on the tool definition (beside name and input_schema, not inside tool_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_format parameter is deprecated — use output_config.format.
  • A schema must declare additionalProperties: false and list its required fields.
Both together
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=[...]
)
Exam trap

Putting strict inside tool_choice. It belongs on the tool definition.

Check your understanding

Where does strict: true belong?

Correct answer: B — As a top-level field on the tool definition
tool_choice only decides which tool runs; it carries no validation flag.

What does output_config.format constrain?

Correct answer: B — The response body
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 app

Source: Claude Docs — Structured outputs · Independent study aid, not affiliated with or endorsed by Anthropic.