Skip to content
itsorted.online
AI guide

Structured Outputs: Getting AI to Fill Forms and Sheets Reliably

If you want AI to read an invoice and create a bill in Xero, or turn an enquiry email into a CRM lead, the AI's answer has to come back in a fixed shape: the same fields, the same names, every time. Structured outputs are the feature in OpenAI's and Anthropic's APIs that forces this. This guide explains what they are in plain terms, how they differ from the older JSON mode, why they make automations far more dependable, and why a perfectly formatted answer can still contain a wrong number.

By IT Sorted teamReviewed 7 min readHow we write guides
in

Key takeaways

  • A JSON schema lists the fields you want, their types and which ones are required.
  • OpenAI says structured outputs ensure replies follow your schema; JSON mode only ensures valid JSON.
  • Both OpenAI and Anthropic note outputs can still break the schema on refusals or token limits.
  • OpenAI states plainly that structured outputs can still contain mistakes.
  • Validate totals, dates and IDs in code, and keep a human review step for payments.
In this guide · 8 sections
  1. 01What structured outputs are, in plain English
  2. 02Structured outputs vs JSON mode
  3. 03Where this helps a small business
  4. 04The limits: right shape, not always right answer
  5. 05How to validate AI output before it reaches your systems
  6. 06Costs and practical details
  7. 07Do it yourself or get help?
  8. 08Frequently asked questions

Short answer

Structured outputs make an AI model reply in a format you define (a JSON schema listing fields and types), so automations can read the answer without breaking. OpenAI and Anthropic both offer it. It guarantees the shape, not the truth: you still need checks on totals, dates and anything that moves money.

What structured outputs are, in plain English

Normally an AI model replies in free text. That's fine for a person, but an automation tool such as Zapier, Make or your own code needs something predictable: a field called invoice_number, a field called total, a date in one format. If the AI sometimes writes "Total: $1,070" and sometimes "the amount due is 1070 SGD", the next step breaks.

A JSON schema is a short description of the answer you want: which fields, what type each one is (text, number, date, yes/no, a fixed list of choices) and which are required. With structured outputs switched on, the model must reply in exactly that shape.

FieldTypeExample value
supplier_nameTextABC Trading
invoice_numberTextINV-20431
invoice_dateDate2026-10-15
totalNumber1070.00
gst_includedYes / notrue
currencyOne of SGD, USD, MYRSGD
A simple invoice schema. The automation reads each field by name.

Structured outputs vs JSON mode

Older models offered a looser setting called JSON mode. OpenAI's structured outputs guide compares them: both produce valid JSON, but only structured outputs make the reply follow your schema. JSON mode can still leave out a field or invent a value outside your list.

Structured outputs

Use this
  • Reply follows your schema: required fields present, types correct
  • Enum fields limited to your list
  • Safety refusals detectable in code
  • Available on current OpenAI and Anthropic models

Best for: Anything an automation reads.

JSON mode

  • Reply is valid JSON
  • No guarantee of fields or types
  • Needs extra checks and retries
  • Kept for older models

Best for: Legacy setups only.

Anthropic's structured outputs documentation describes the same idea for Claude: JSON outputs constrain the response to your schema, and strict tool use applies the same guarantee to the inputs Claude sends to your functions. It lists current Opus, Sonnet and Haiku models as supported.

Where this helps a small business

Structured outputs are what make AI usable inside ordinary business automations, rather than only in a chat window:

  • Supplier invoices to Xero or QuickBooks: read a PDF, return supplier, number, date, line items and total, then create a draft bill. Our guide to AI invoice and receipt extraction covers the full flow.
  • Enquiry emails to a CRM: name, company, phone, service wanted and urgency, sent straight into a lead record.
  • Classifying messages: tag each support email with one category from a fixed list, so it lands with the right person.
  • Spreadsheet rows from documents: delivery orders, quotes or forms turned into one clean row each.

In every case the AI step sits between a trigger and an action, often connected through webhooks or APIs. Our guide to APIs and webhooks explains how those pieces connect.

The limits: right shape, not always right answer

This is the part vendors are careful to state and buyers often miss. OpenAI's guide says outright that structured outputs "can still contain mistakes", and that if the input has nothing to do with the schema, the model may fill the fields with invented values. A correctly shaped invoice with the wrong total is still wrong.

Both vendors also list cases where the reply may not match the schema at all:

  • Refusals: if the model declines a request for safety reasons, the refusal takes priority over the schema.
  • Token limit reached: if the answer is cut off, the JSON can be incomplete. Anthropic says to retry with a higher max_tokens value.
  • Unsupported schema features: both vendors support only a subset of JSON Schema. Anthropic lists numeric limits like minimum and maximum as unsupported, and OpenAI caps schemas at 5,000 properties and 10 levels of nesting.
  • Capitalisation of choices: Anthropic notes enum values may come back with different capitalisation, so compare them case-insensitively.

How to validate AI output before it reaches your systems

A dependable automation adds checks around the AI step. These are usually a few lines in the automation tool or in code.

  1. Define a tight schema

    Required fields only where they always exist, fixed lists for categories and currencies, a date format. Add a field like "confidence" or "not_an_invoice" so the model can say the input doesn't fit.

  2. Check the stop reason

    Treat refusals and cut-off responses as failures and send them to a person, not to the next step.

  3. Check the numbers add up

    Line items should sum to the subtotal; subtotal plus GST should equal the total. Reject if not.

  4. Check against what you know

    Is the supplier in your contact list? Is the invoice number already in Xero? Is the date in the past few months?

  5. Route exceptions to a person

    Anything that fails a check goes to a review queue or an email, with the original document attached.

  6. Sample the successes

    Once a month, compare a handful of processed documents with the originals to catch quiet errors.

Costs and practical details

Structured outputs don't have a separate price; you pay normal token prices. Anthropic notes it adds a short system prompt explaining the format, so input tokens rise slightly, and the first request with a new schema is slower while it is compiled, with compiled schemas cached for 24 hours from last use. For per-token prices, see our LLM API pricing comparison.

Anthropic also notes that while prompts and responses are covered by its zero data retention arrangements, the schema itself is cached separately, so don't put personal data in field names or fixed lists. That is good practice with any vendor.

Do it yourself or get help?

Zapier and Make both have AI steps, and many let you define output fields, which gives you some of this without code. The validation checks above are what most do-it-yourself setups skip, and they are what stops a bad extraction from becoming a bad payment.

Our Workflow Automation (S$390 per workflow) builds one workflow of up to five steps on Make, Zapier or Google Apps Script in your account, with error alerts to your email and documentation. For larger jobs, such as an extraction tool with a review screen and checks against your accounting data, our Custom Tool or Dashboard starts from S$1,990 with a free written scope.

Frequently asked questions

A feature in AI APIs that makes the model reply in a format you define, usually a JSON schema listing field names, types and required fields. Instead of free text, you get the same fields every time, which automation tools and code can read reliably. OpenAI and Anthropic both offer it on current models.

JSON mode only guarantees the reply is valid JSON. Structured outputs also make it follow your schema, so required fields are present, types are correct and choice fields stay within your list. OpenAI recommends structured outputs over JSON mode where the model supports it, and keeps JSON mode mainly for older models.

Yes. They guarantee the format, not the facts. OpenAI's documentation says structured outputs can still contain mistakes, and that unrelated input may lead the model to fill fields with invented values. Refusals and replies cut off by token limits can also break the format. Validate totals, dates and IDs before anything is posted or paid.

Partly. Both have AI steps where you can name the output fields you want, which gives a similar result for simple jobs. For strict schemas, validation and error routing, you may call the OpenAI or Anthropic API directly from the automation using an HTTP step, or use a small script alongside the workflow.

There is no separate fee; you pay the model's normal token prices. Anthropic notes that it adds a short system prompt explaining the expected format, which slightly increases input tokens, and that the first request with a new schema has extra latency while it is compiled. Compiled schemas are cached for 24 hours from last use.

Rather have it done for you?

Fixed price, set up in your own accounts.

Order online, get a written scope, and keep full ownership of everything we set up. Questions first? Ask us in writing.