Key takeaways
Structured outputs make model responses easier for applications to consume, but do not guarantee factual accuracy.
JSON syntax, schema compliance and business correctness are three separate checks.
Represent missing information explicitly instead of encouraging the model to invent mandatory values.
Keep permissions, financial decisions and other consequential actions outside model control.
Measure field-level accuracy, false acceptance, human correction and total cost per accepted record.
Use simpler rules or direct integration when the source already provides reliable structured data.
A good AI answer is not always a usable business result
Imagine a customer emailing an online retailer: “My headphones arrived damaged. Can someone arrange a replacement?” An AI assistant understands the complaint and writes a helpful summary. The customer service team is impressed. But the application responsible for creating support tickets needs a category, an order reference, a requested resolution and a review status, not a beautifully written paragraph.
Ask the same model to process another email and it may change the field names, omit a missing order number or describe the problem in different words. A developer then has to write increasingly complicated parsing rules, and employees end up correcting records that AI was supposed to prepare automatically.
This is where structured outputs in LLM applications become valuable. They turn the flexible language generated by a large language model (LLM) into a predictable data structure that other software can consume.
The distinction matters for organisations connecting generative AI to operational processes. An assistant that can explain a problem is useful. An application that can represent the problem consistently, identify what is missing and hand it to the right workflow is easier to integrate and govern. However, a predictable format does not automatically make the information correct.
From a conversation to a data contract
A structured output is a model response organised according to a predefined format. One widely used format is JavaScript Object Notation (JSON), which represents information as named fields, values, objects and lists. A JSON Schema describes the rules that a valid response must follow.
Think of a schema as a digital form. A service desk may require a complaint category selected from an approved list, an order reference that can be absent, and a Boolean value indicating whether the case needs manual review. Rather than asking an AI model to invent its own format for each response, the application provides a contract describing the expected result.
The schema can specify which fields must be present, the types of values they accept and whether unexpected fields are allowed.[1] An application can use that contract to display information in a consistent interface, send it to a review queue or prepare it for another service.
The contract should reflect the actual business process. If the next system does not use a particular field, collecting it may create unnecessary cost and privacy exposure. Start with the information needed for the next decision.
Three approaches that look similar but behave differently
Developers often begin by writing a prompt such as “Return the answer as JSON.” That may be enough for a prototype, but there are important differences between asking for a format and enforcing it.
Prompt-based formatting | The model is instructed to produce JSON or another agreed format. It is flexible and easy to prototype, but the application must expect formatting mistakes and schema violations.
JSON mode | On APIs that offer it, this mode targets syntactically valid JSON. A response can still contain unexpected fields, incorrect types or missing business information. A separate schema check remains necessary.
Schema-constrained generation | The model is given a supported schema and generation is restricted to the permitted structure. This is preferable for many machine-consumed outputs when the selected model and API support the required constraints. Applications must still handle incomplete responses and refusals.
OpenAI distinguishes JSON mode from its schema-enforced Structured Outputs feature.[2] Anthropic and Google also document schema-based generation capabilities.[3][4] The interfaces and supported schema features differ, so do not assume that a contract working with one provider will work unchanged with another.
What a structured support ticket actually looks like
Consider the damaged-headphones email from the opening. The application needs to capture the nature of the complaint without pretending to know information the customer has not supplied. One possible response is the following JSON object:
{"category": "damaged_item", "order_id": null, "requested_resolution": "replacement", "needs_review": true}
The category is drawn from an approved set of complaint types. The order reference is explicitly null because it was not supplied. The requested resolution captures what the customer wants, rather than promising that the replacement has been approved. The review flag directs the application towards exception handling.
A corresponding contract could be expressed using the following compact JSON Schema. This is a provider-neutral schema definition, not a complete API request:
{"type":"object","properties":{"category":{"type":"string","enum":["damaged_item","delivery_delay","other"]},"order_id":{"type":["string","null"]},"requested_resolution":{"type":["string","null"]},"needs_review":{"type":"boolean"}},"required":["category","order_id","requested_resolution","needs_review"],"additionalProperties":false}
The schema admits an explicit null for unknown information rather than demanding a plausible order reference. All four keys are required, but two may contain null. Extra keys are disallowed. The application should calculate or override the review flag from trusted policy, not rely on the model to decide whether an incomplete ticket can proceed.
Notice what is not in the response: a refund amount, a replacement authorisation or a claim that the customer is entitled to compensation. Those decisions require verified records and business rules.
Why perfectly formatted data can still be wrong
There are three different questions to ask about every model-generated record. Can the software read it? Does it satisfy the data contract? Does the information match reality and the applicable business rules?
A response can pass the first two checks while failing the third. Imagine the AI extracts an invoice total of 12,500 when the document actually says 1,250. Both numbers are valid numeric values. A schema cannot establish which one appears in the source document.
This matters especially in finance, insurance and healthcare, where a misplaced decimal, inaccurate classification or unsupported interpretation may have significant consequences. Combine format validation with independent checks such as source reconciliation, permitted value checks, verified record lookups and appropriate human review.
For document intelligence, retain a source locator or short evidence excerpt where the contract and privacy requirements allow it. Check that the evidence actually exists and supports the extracted value. A model-generated page number is not proof on its own.
Where information is unavailable, ambiguous or contradictory, allow the system to express that state. An explicit unknown is often more useful than a confident but invented answer.
Where the opportunity is greatest
Structured generation is particularly useful where the same kind of information repeatedly moves from an unstructured source into a defined operational process.
Finance and procurement: prepare invoice fields for reconciliation with purchase orders, supplier records and tax rules. Payment approval remains with the authorised financial workflow.
Insurance: organise incoming claim descriptions into incident types, supplied documents and missing-information flags. Coverage and settlement decisions require independent assessment against policy terms and appropriate oversight.
Customer operations: classify enquiries and prepare draft tickets or customer relationship management records. The system can use approved categories to route cases without requiring staff to retype the original message.
Enterprise knowledge assistants: return an answer with source identifiers and an explicit indication that available evidence is insufficient. Validate those identifiers against the retrieved documents and enforce access permissions before presenting the answer.
Not everything needs this treatment. When a user simply wants brainstorming, an explanation or creative writing, natural language is often the appropriate output. Structure is most valuable when a downstream application needs dependable fields or predictable presentation.
Design the schema around what happens next
A schema becomes an interface between the AI component and the rest of the application. Treat it as an engineering asset, not a formatting instruction hidden inside a prompt.
Begin with the receiving system. Identify the fields it needs, their meanings, permitted categories, units and missing-value rules. Money needs an explicit currency and a consistent representation; dates need an agreed convention; identifiers need verification against the system that owns them.
Keep the initial contract small. Clear descriptions and well-defined categories help distinguish closely related cases. An “other” or “unknown” category can prevent forced classification when the input genuinely does not fit, but monitor its frequency to discover gaps in the taxonomy.
Constrained decoding restricts the possible next tokens during generation according to the permitted grammar. This controls structure without proving that the selected content is supported by the input. Complex schemas can introduce provider-specific limits and additional processing overhead.[3]
Version the schema with the application. Renaming a field or adding a mandatory property can break a consumer even if the new response is valid against the revised contract. Test schema changes together with prompt changes, model upgrades and downstream integrations.
Safe hand-offs: generation, validation and execution
A practical implementation separates the model from the systems that create business effects. The application first obtains the relevant input, applies access restrictions and sends the authorised information to a suitable model with the response schema.
Before consuming the output, check the API response status and distinguish a successful generation from a refusal, timeout or incomplete response. Decode the complete result, apply schema validation and run independent business checks. Route invalid or uncertain results to a controlled exception path rather than silently substituting defaults.
If the workflow involves tools, use a separately defined tool interface. Structured responses describe data; function calling allows a model to request an application operation. Some APIs support strict schemas for both, but perfectly formed tool arguments do not establish that the operation is permitted.[2][3]
For instance, an AI model may propose a replacement request for an existing order. Only the application should verify the authenticated customer, eligibility, authorisation and any approval requirement. Use durable request identifiers and idempotency controls to avoid duplicate actions when a service retries a request.
Treat free-text fields as untrusted input. A valid JSON string can still contain malicious instructions, unexpected markup or unsafe content. Use appropriate output encoding, parameterised database operations, restricted tool permissions and secure data handling. Never let model-generated text override trusted access controls.
Measure completed work, not just valid JSON
A useful pilot should compare the structured approach against the existing manual process or prompt-based implementation using representative, authorised records. Include missing fields, unclear descriptions, conflicting data, different languages and unusual input lengths.
Measure schema compliance across attempted outputs, with refused and incomplete responses reported separately. Then measure field-level correctness against reviewed reference values, including whether the model correctly leaves unknown information unset. Track false acceptance: incorrect records that pass all automated checks.
Operational measures should include the proportion of cases that reach the appropriate next step, the human correction rate, exception volumes, end-to-end turnaround time and total cost per accepted record. Include inference, validation, retries and review effort in that cost.
These measures expose the difference between a technically reliable integration and a commercially useful one. If the schema pass rate improves but staff still need to correct the same number of records, the problem may be weak extraction, ambiguous business definitions or inadequate source evidence rather than formatting.
Use a controlled release and examine results by document type, language or complaint category. A strong overall score can hide poor performance on an important subset of work.
Start with one business hand-off
Before investing in a broad AI automation programme, identify one process where employees repeatedly turn emails, documents or conversations into records. Decide exactly what the receiving system needs and what errors would be unacceptable.
A small, measurable pilot can establish whether schema-constrained generation offers enough benefit over conventional rules, templates or existing document extraction tools. If the source already provides reliable structured data, an ordinary integration may be the better option.
If your organisation is exploring an AI assistant that needs to integrate with enterprise applications, a focused review of its output contracts, validation rules and exception paths can help identify where structured generation will add genuine value.
The goal is not simply to make an LLM speak JSON. It is to make the transition from flexible language to dependable business information explicit, testable and safe.
References and further reading
[1] JSON Schema. Understanding JSON Schema: Object. https://json-schema.org/understanding-json-schema/reference/object
[2] OpenAI. Structured model outputs, API documentation. https://developers.openai.com/api/docs/guides/structured-outputs
[3] Anthropic. Structured outputs, Claude Platform documentation. https://platform.claude.com/docs/en/build-with-claude/structured-outputs
[4] Google. Structured outputs, Gemini API documentation. https://ai.google.dev/gemini-api/docs/structured-output
Apply the approach
Consider a customer who reports damaged headphones and requests a replacement without providing an order number. The AI prepares a support record; the application must verify eligibility and obtain missing information before any replacement can be authorised.
The issue is mapped to a predefined support category.
No order number was supplied. The application must obtain or verify it instead of inventing one.
Captures the customer’s requested remedy, not an approved action.
The record is incomplete. Trusted application rules should determine the next step.
Put the approach into practice
- 01Choose one repetitive business process and define the receiving system’s information needs.
- 02Design a small, versioned schema with explicit missing-value rules and permitted categories.
- 03Evaluate schema-constrained generation on representative inputs and implement independent validation and exception handling.
- 04Separate generated records and proposed actions from authentication, approval and execution controls.
- 05Compare field correctness, correction effort, false acceptance and cost per accepted record against the existing process.
Frequently asked questions
Are structured outputs and JSON Schema the same thing?
No. A structured output is a response with a defined organisation. JSON Schema is one way to express the rules for the shape and values of a JSON response. A provider may enforce a supported subset of those rules during generation.
Do structured outputs eliminate hallucinations?
No. A correctly formatted response can still contain false facts or invented values. Use reliable source information, independent validation and appropriate human review to establish business correctness.
Can I use the same schema with every LLM provider?
Not necessarily. Providers differ in their supported schema keywords, complexity limits, APIs and model capabilities. Test the schema with each intended model and validate the result against the application’s full contract.
What if an AI model cannot complete a structured response?
Handle refusals, incomplete generations, timeouts and service errors explicitly. Retry only under a bounded policy where appropriate, or route the work to an approved alternative or manual review. Do not treat an incomplete result as a valid record.
Should I use structured outputs for tool calling or for the final answer?
Use an output schema for a final response that must fit a data contract. Use defined tool interfaces when the model needs to request operations. In both cases the application remains responsible for permission checks and validation.
Do structured outputs reduce AI operating costs?
They may reduce parsing failures, unnecessary retries and manual corrections. The net effect depends on model usage, schema complexity, validation and review overhead. Measure total cost per accepted record at an agreed quality level.