OpenAI Enforces Exact JSON Responses with Structured Outputs
OpenAI is adding Structured Outputs to its API so GPT-4o and GPT-4o mini can respond according to a JSON schema defined by the developer. The feature reduces a common problem when connecting models to applications and databases.
OpenAI introduced Structured Outputs on Tuesday, an API feature that lets developers require models to return data in a specific JSON structure. The change targets a practical problem: a model can give a person a correct answer and still be useless to an application if it changes the expected format.
The feature is available on the GPT-4o-2024-08-06 and GPT-4o mini-2024-07-18 models. According to OpenAI, its internal tests put GPT-4o with Structured Outputs at 100% compliance with complex schemas, compared with less than 40% for GPT-4-0613 using earlier methods.
From valid JSON to usable JSON
JSON is a widely used text format for exchanging data between programs. A retailer, for example, might need a model to extract a product name, category, maximum price and list of filters from a query. It is not enough for the model to respond in JSON: it must use exactly those fields, with the expected data types and without inventing additional ones.
Until now, developers could ask for a JSON response or describe the format in the message sent to the model. That reduced errors but did not eliminate them. The model could omit a required field, return a number as text or add an explanation before the JSON object. Any of those failures requires validation, retries and additional rules in the software receiving the response.
Structured Outputs lets developers define a schema using JSON Schema, a specification that describes which data is admissible: required fields, possible values, nested objects or lists. For compatible schemas and requests that are not refused, the API aims to make the response conform to that definition when the strict: true option is enabled.
Two ways to use the feature
OpenAI has integrated this capability into two parts of its API. The first is function calling, or tools: the developer describes an action the model can request, such as checking a catalog, booking an appointment or looking up an order. In strict mode, the arguments for that call must follow the declared schema.
The second is the response format. Instead of simply asking for JSON, an application can send a schema using the json_schema format and receive output ready to be processed by code.
This does not mean the model suddenly knows data it did not know before, nor that it stops making reasoning errors. It guarantees the form of the response, not the truth of its content. If asked to classify a complaint or extract data from an ambiguous document, it can still misinterpret the text; the difference is that it will deliver that interpretation in a predictable structure.
Less integration work
The improvement is especially valuable in use cases where the model is one component in a larger process rather than an isolated chatbot. It can turn invoices into records, convert conversations into forms, extract information from contracts, generate interfaces from instructions or feed customer service systems.
It also narrows the gap between a prototype and a product. A developer can put together a demo with free-form responses in minutes, but deploying it requires handling exceptions: missing fields, invalid formats and outputs that break an automation. Enforcing the schema does not replace business checks — such as verifying that an amount actually exists in a database — but it removes a common class of formatting failures.
OpenAI supports JSON Schema within a subset of the specification, a reasonable restriction that allows the system to guarantee compliance. The documentation also covers safety refusals: if the model refuses a request, the application can distinguish that refusal from a normal structured response.
The feature comes with no specific additional charge: it uses the pricing for compatible models. GPT-4o costs $5 per million input tokens and $15 per million output tokens; GPT-4o mini costs 15 cents and 60 cents, respectively.
The move shows where a less visible part of the competition between models is taking place: not just in answering a question better, but in behaving predictably enough to integrate into real-world software. For companies, that formatting reliability may matter more than a marginal improvement in conversational quality.