[KongchangAI]
Concept

JSON Schema

JSON Schema is a declarative specification language for describing and validating the structure of JSON data, itself written in JSON format. It defines rules covering data types, property constraints, required fields, and enumerated values to validate and document JSON data. JSON Schema is widely used in API design, configuration file validation, form validation, and automated code generation, serving as a key tool for ensuring interoperability and data consistency.

Core Facts

Timeline (last 90 days)

Oct 15

JSON Schema is standardized by the IETF as a series of draft documents, and draft-7, which the SDK uses, is one of those versions.

Unverified50%
Oct 15

When handing the schema to the model, if the model is responsible for producing the raw input, `io: "input"` should be used.

Unverified50%
Oct 15

In `io: "input"` mode, the `.transform()` on the `sku` field appears as an ordinary string in the JSON Schema; in the default `io: "output"` mode, the converter throws an error.

Unverified50%
Oct 15

In the refund extraction schema demonstration, the `.refine()` on the `note` field leaves only `"type": "string"` in the JSON Schema, while the object-level `.refine()` is lost entirely.

Unverified50%
Oct 15

In the refund extraction schema demonstration, `.regex(...)` is converted in JSON Schema to `pattern`, `.positive()` is converted to `exclusiveMinimum: 0`, `z.enum` is converted to `enum`, and `z.iso.date()` is converted to `format: "date"` plus `pattern`.

Unverified50%
Oct 15

Model APIs such as OpenAI's and Anthropic's accept only a subset of JSON Schema keywords, and the remaining constraints are either ignored or downgraded to natural language descriptions.

Unverified50%
Oct 15

JSON Schema can only express structural and simple value constraints such as types, enums, regex patterns, date formats, numeric upper and lower bounds, required fields, and array lengths; it cannot express arbitrary custom functions, cross-field comparisons, or transformations that change the shape of the data.

Unverified50%
Oct 15

Structural descriptions for AI agents are closer to declarative interface definitions, for example using JSON Schema to specify data shapes, dependency graphs to make clear that only one-way references between modules are allowed, and signatures to define function contracts.

Unverified50%
Oct 15

Pydantic/JSON typed Schemas eliminate 92% of tool call failures

Unverified50%
Oct 15

Some APIs enable constrained decoding to force the model to output JSON conforming to the Schema, while others only use the Schema as a hint, so enums can greatly reduce but not completely eliminate the probability of the model fabricating values.

Unverified50%

40 more timeline events

All Facts (20)

Verified

Each tool in MCP has a strict JSON Schema description, including the name, functional description, and parameter specifications

90%
Verified

Function Calling机制中,开发者将工具的名称、功能描述、参数Schema(通常为JSON Schema格式)注入到模型的请求中,模型输出结构化的JSON而非自然语言来调用工具

80%
Verified

Agents use the Tool Calling mechanism to allow models to output calling intent in a structured JSON format, with external programs executing the actual operations and feeding results back to the model.

80%
Verified

JSON Schema is a specification for describing and validating JSON data structures, capable of defining field requirements, data types, and value ranges.

80%
Verified

Structured output imposes constraints on token generation during the decoding phase through JSON Schema or function-calling mechanisms, which is fundamentally different from requesting JSON-format output in the prompt.

80%
Verified

Defining typed JSON Schema for tools can reduce format errors and hallucinated parameter filling during model calls, improving call success rates.

75%
Verified

The basic principle of tool calling is that the model identifies scenarios requiring external capabilities, outputs a structured function call request (usually in JSON format), and after the external system executes it, the result is returned to the model to continue reasoning.

75%
Verified

JSON Schema is a declarative specification based on JSON format, originating from a community draft in 2009, with standardization work advanced by the IETF in RFC 8927 and subsequent drafts.

75%
Verified

Setting additionalProperties: false in a JSON Schema rejects any extra fields not explicitly declared in the schema, eliminating the possibility of the model inventing additional fields.

75%
Verified

The latest version of JSON Schema is Draft 2020-12, maintained by json-schema.org.

75%
Verified

JSON Schema is maintained by the IETF, and the current version is Draft 2020-12.

70%
Verified

Swagger已更名为OpenAPI Specification,是一套用于描述RESTful API的标准化规范,以JSON或YAML格式定义API信息,目前业界广泛使用OpenAPI 3.0/3.1版本

70%
Verified

For AI, tools are essentially a menu described in JSON Schema; the clearer the description, the higher the accuracy with which the model selects tools.

65%
Verified

In the tool-calling mechanism, developers attach a tool description list in JSON Schema format when calling the LLM API, and the model outputs call parameters in structured JSON format

65%
Verified

JSON Mode only guarantees that the output is valid JSON without constraining the field structure; Structured Outputs enforces output conforming to a predefined JSON Schema at the syntactic level by applying a finite state machine (FSM) to constrain the token sampling path during the decoding phase.

65%
Verified

The schema for tool calls is essentially a JSON Schema specification that describes the tool name, parameter names, type constraints, and required fields.

65%
Verified

MCP规定了工具描述的标准格式,包括工具名称、参数schema、返回值格式

65%
Verified

Taking GPT-4o as an example, the JSON Schema description of each tool consumes an average of 200–500 tokens, and when the system integrates 50 tools, the tool description section alone consumes 10,000 to 25,000 tokens.

65%
Unverified

Hermes模型从微调阶段就大量使用结构化输出训练数据,使模型天然倾向于生成格式正确的JSON

80%
Unverified

当前版本的ChatGPT支持通过JSON Schema或函数调用(Function Calling)约束模型输出特定格式的数据结构

80%

Source Articles