AITraining2U

Programs

Resources

Case Studies

Quick Links

Enquire Now
Domain 3 · 20%% of exam

JSON Schema support and limits

What the schema engine will and will not enforce.

4 min read · Lesson 2 of 12 in this domain

Structured outputs are enforced during generation, not checked afterwards, and that is what makes them reliable. It also explains the limits. The engine supports the parts of JSON Schema that describe shape — types, enums, unions, references — and not the parts that describe ranges, like minimum or maxLength. The Python and TypeScript SDKs paper over this by stripping unsupported keywords before sending and validating them client-side, so your constraint still holds; it is simply enforced in a different place than you might assume.

Key points
  • Supported: basic types, enum, const, anyOf, allOf, $ref/$defs, common string formats (date-time, date, email, uri, uuid…), and additionalProperties: false.
  • Not supported: recursive schemas, numeric constraints (minimum, maximum, multipleOf), string-length constraints, and complex array constraints.
  • The Python and TypeScript SDKs strip unsupported constraints before sending and validate them client-side instead.
  • A new schema incurs a one-time compilation cost on first use; later requests hit a 24-hour schema cache. That explains a slow first call.
  • Incompatible with citations (returns 400) and with message prefilling.
  • On stop_reason: "max_tokens" the JSON may be truncated — the schema cannot manufacture tokens after the cap.
Reference
Feature Supported?
enum / constYes
anyOf / allOf / $refYes
additionalProperties: falseRequired
Recursive schemasNo
minimum / maximumNo (SDK validates client-side)
minLength / maxLengthNo (SDK validates client-side)
Worked example

Why the first call is slow. Your extraction endpoint takes 4 seconds on its first request of the morning, then 1.2 seconds for the rest of the day, then 4 seconds again the next morning. Nothing is wrong. A schema the engine has not seen must be compiled into a grammar before generation, and the result is cached for 24 hours. If you are benchmarking latency, discard the first call per schema — and if a schema is used rarely enough that every call is a cold one, that compilation cost is part of its real price.

Exam trap

"It is schema-valid so it must be complete" — a truncated response is neither.

Check your understanding

Which is NOT supported by structured outputs?

Correct answer: B — Recursive schemas and numeric ranges
minimum/maximum and minLength/maxLength are also unsupported; the SDKs validate them client-side.

stop_reason is max_tokens on a schema-constrained call. What do you conclude?

Correct answer: B — It may be truncated and incomplete
Schema enforcement cannot manufacture tokens after the cap. Raise max_tokens or stream.

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.