Skip to content
47% off: the complete course for $79 (reg. $149)Order now →
AI Builder

AI builder glossary

JSON Schema

A standard vocabulary for describing the shape of JSON data, used by model APIs to define structured outputs and the arguments that tools accept.

JSON Schema describes what valid JSON looks like: which properties exist, their types, which are required, allowed enum values, array item shapes, and nested objects. Model providers use it in two places. Structured outputs use a schema to define the response format, and tool definitions use one to describe the arguments each tool accepts.

Most builders don't write JSON Schema by hand. In TypeScript you define a Zod schema, in Python a Pydantic model, and a helper converts it, which also gives you a typed object and runtime validation from the same definition. The schema still matters, though, because it is what the model actually reads.

Two details trip people up. Strict modes typically require every object to forbid additional properties and to list which fields are required, and providers support only a subset of JSON Schema features, so exotic constraints may be rejected or ignored. Check the provider's documentation for what is supported.

Treat descriptions as instructions. A field called status with no description invites guessing; one that explains each allowed value and when to use unknown produces far better output.

Example

A ticket-routing tool defines its arguments with a schema: team as an enum of five values, priority as an enum of low, normal, or urgent, and reason as a short string, each with a description the model reads before choosing.

Learn more in the course

Related terms

Go from definitions to doing

Learn to build AI-powered apps in 132 practical lessons.