Skip to content

GlossaryFloor 2 · The Harnessthe block and its bolted-on plates: what gets added to itFloor 2 · The Harness

structured output

No. 043 · v2026-08FR: sortie structurée

A structured output is a response constrained to follow a precise shape, so that another piece of software can read it directly. Like a form rather than a free letter: the boxes are imposed, which says nothing about the accuracy of what you write in them.

What it is not

A structured output guarantees only the shape. Getting a well formed result, with every expected field and the right types, says nothing about the accuracy of the values: an invented date is still a valid date, and a required field even pushes the model to fill it in rather than abstain. Nor is it a business guarantee, since the shape accepts a negative amount, a code that does not exist or a client who never existed. Structure makes a response readable by a machine, it does not make it true.

In depth

The need

The need comes from the wiring. As long as a response is read by a person, its presentation matters little; as soon as it feeds another piece of software, the slightest variation breaks the chain, and you do not build automation on free text. Constraining the output means describing the expected shape in advance, fields and types included, then accepting only a conforming response. Depending on the case, the constraint is merely requested in the instructions or genuinely imposed during the production of the text, and the two do not give the same guarantees: asking for a shape is hoping; imposing it is making any other outcome impossible.

Same mechanism, other destination

The mechanism is the same as that of a tool call, except that the destination changes: in one case the shape serves to request an action, in the other to deliver a usable result. A shape constraint also has a rarely measured cost, since the description of the format occupies the context and is read again on every request. On tasks that call for reasoning, demanding a rigid shape from the outset sometimes degrades the quality, the model no longer having room to unfold its reasoning before concluding. The usual remedy consists in separating the two moments: let it answer first, then constrain the formatting.

Shape is not substance

The central trap is the confidence that shape inspires. A tidy response, with its fields and its values, reads like verified data when it remains a plausible production, and this appearance of rigour then travels through the whole chain without anyone questioning it. The practical consequence is that a structured output calls for business validation downstream, distinct from the check on the shape: consistency of the values with one another, real existence of the identifiers, ceilings, rules of the domain. The second trap is the absence of a way out, because without a field allowing it to say that it does not know, a constrained model always fills in: better to plan for uncertainty than to discover it later in the data.

Under the hood3 steps · the real shape of the objects

A structured output is a schema plus a constraint. The schema can be read; the constraint plays out at one precise point in the production of the text, and it is that point which separates a hoped for shape from a guaranteed one.

  1. 01

    The schema, and what it promises

    The schema describes the expected shape, field by field. It travels with the request, which makes it a cost per turn rather than a setting made once: lengthening a schema is paid for on every call.

    json
    {
      "name": "invoice_verdict",
      "schema": {
        "type": "object",
        "properties": {
          "amount_excl_tax": { "type": "number" },
          "currency": { "type": "string", "enum": ["EUR", "USD", "CHF"] },
          "issue_date": { "type": "string", "format": "date" },
          "confidence": { "type": "string", "enum": ["certain", "unsure", "unreadable"] }
        },
        "required": ["amount_excl_tax", "currency", "issue_date", "confidence"],
        "additionalProperties": false
      },
      "strict": true
    }
    
    enum
    A closed list. It is the most useful constraint of the lot: it makes a value outside the list impossible, where an instruction in plain language would only make it improbable.
    confidence
    The way out, and the field everyone forgets. Uncertainty is planned for in the schema, failing which it comes back out disguised as a value, and gets discovered much later in the data.
    strict
    The flag that switches from a requested shape to an imposed one. Everything turns on it, and the next step shows why.

    The trapThis is the rarely measured cost layer 2 mentions, and it can be seen here: the constraint applies from the very first fragment produced. Hence the third step, which separates the two moments.

  2. 02

    Hoping, or imposing

    Here is the difference, at the exact point where it occurs. At each step the model proposes a distribution over the possible tokens; constraining consists in cancelling, before the draw, those that would lead outside the schema. So it is not a check after the fact: it is an amputation of the outcomes.

    js
    // A · the shape REQUESTED: you beg, then you check, then you start over
    let raw = await model.answer({ messages: [...msgs, instruction('Reply in JSON.')] });
    let parsed = tryToRead(raw);              // may fail: text before, trailing comma...
    if (!parsed) raw = await model.answer({ messages: [...msgs, complaint(raw)] });
    
    // B · the shape IMPOSED: at each step, tokens outside the schema are discarded
    function nextToken(scores, schemaState) {
      const allowed = automaton.acceptableTokens(schemaState);  // derived from the schema
      for (const t of Object.keys(scores)) {
        if (!allowed.has(t)) scores[t] = -Infinity;             // <- the outcome vanishes
      }
      return draw(scores);
    }
    
    tryToRead
    All the defensive code that a real constraint makes pointless: a preamble to strip, a code block to unwrap, one comma too many, fanciful quotation marks.
    -Infinity
    The token becomes impossible, not improbable. It is the only guarantee of shape that exists, and it is not obtained by asking more politely.

    The trapIt is the same mechanics as a tool call, down to the destination, as layer 2 says. A provider that accepts a schema for its tools but not for its responses therefore does not have a technical limit, it has a limit in the surface it exposes.

  3. 03

    What the shape does not say

    A conforming response remains a plausible production. This is the central trap of the entry, and here it is in its most concrete form: the check on the shape has passed, and nothing has been verified yet.

    js
    const r = { amount_excl_tax: 1240.00, currency: 'EUR',
                issue_date: '2027-13-45', confidence: 'certain' };
    
    validate(r, schema).ok;   // true  <- the SHAPE is beyond reproach
    
    // what is left to do, and what nobody does in place of the business
    const checks = [
      () => isARealDate(r.issue_date),                       // false: month 13, day 45
      () => r.amount_excl_tax > 0 && r.amount_excl_tax < 1e6, // ceiling of the domain
      () => existsInRecords(r.supplier_number),              // does the identifier exist?
      () => r.confidence !== 'certain' || sourceIsLegible(),  // confidence is declared,
    ];                                                        // so it proves nothing
    
    if (!checks.every((c) => c())) reject(r);
    

    The trapThe fourth line is the most treacherous: a confidence field is filled in by the same mechanism as the rest, so “certain” is not a measurement, it is one more prediction. It serves to collect a doubt when there is one, never to do without one.

Shown elsewhere
  • tool callingthe same mechanism of imposed shape, turned towards action instead of a result
  • contextwhere the schema is added, and read again, on every request

What variesField names vary: the schema is declared sometimes under “response_format”, sometimes under a tool name, and the flag for a real constraint changes name from one provider to another. What does not vary: the constraint, when it is real, is enforced as each fragment is drawn and not after, and no schema, however strict, passes the slightest judgement on the truth of the values it frames.

Relations where the neighbours live

Check 3 questions · click your answer

Level 1 · Recognise

A system always returns a result containing the fields “name”, “date” and “amount”. What does this regularity guarantee you?

Level 2 · Distinguish

A required field “invoice number” is filled in although the document carried none. Why?

Level 2 · Distinguish

What is the difference between a structured output and a tool call?

Try it 1 practice

Concrete things to try where this term comes up, in ten minutes.

Who works with this 1 role

The roles for which this term is part of the ordinary work.

No. 043 · v2026-08 · first written in · editorial responsibility Anthony Capirchio

Lexigraph, "Structured output", v2026-08, https://www.lexigraph.org/en/structured-output/, CC BY 4.0.

Report

What goes with your message

Entry · Structured output
No. 043 · v2026-08 · /en/structured-output

What is this about
0 / 600

It is used to reply to you, and for nothing else. What is recorded