# 25.11 How today's tools realize it (/building-ai-workers/prompts-and-structured-output/how-todays-tools-realize-it)

---
type: Document
title: "25.11 How today's tools realize it"
description: "What Claude, OpenAI and open-source runtimes do with a schema and with an answer that is no answer, and which jobs stay in your code."
status: stable
order: 325.11
ksor:
  owner: team:panaversity
  audience:
    - public
  approval:
    by: process:panaversity
    at: 2026-11-30T00:02:23Z
chapter: '25'
part: III
expert_status: co-build
concepts: [ "25.11" ]
last_verified: '2026-11-29'
sources:
  - id: anthropic-refusals-and-fallback
    title: Refusals and fallback (verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback
  - id: anthropic-structured-outputs
    title: Structured outputs (verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/build-with-claude/structured-outputs
  - id: openai-text-generation
    title: Text generation, OpenAI API docs (verified 2026-11-29)
    resource: https://developers.openai.com/api/docs/guides/text
  - id: anthropic-stop-reasons
    title: Stop reasons and fallback (Anthropic, verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons
  - id: claude-code-headless
    title: Run Claude Code programmatically (Anthropic, verified 2026-11-29)
    resource: https://code.claude.com/docs/en/headless
  - id: agent-sdk-structured-outputs
    title: Get structured output from agents (Anthropic, verified 2026-11-29)
    resource: https://code.claude.com/docs/en/agent-sdk/structured-outputs
  - id: openai-structured-outputs
    title: Structured model outputs (OpenAI, verified 2026-11-29)
    resource: https://developers.openai.com/api/docs/guides/structured-outputs
  - id: ollama-structured-outputs
    title: Structured outputs (Ollama, verified 2026-11-29)
    resource: https://docs.ollama.com/capabilities/structured-outputs
  - id: llamacpp-grammars
    title: 'GBNF guide: JSON Schemas to GBNF (llama.cpp, verified 2026-11-29)'
    resource: https://github.com/ggml-org/llama.cpp/blob/master/grammars/README.md
  - id: lmstudio-structured-output
    title: Structured output (LM Studio, verified 2026-11-29)
    resource: https://lmstudio.ai/docs/developer/openai-compat/structured-output
generated:
  at: 2026-11-30T00:02:23Z
  by: esl-rewrite/1.2.0+ksor.1
trust_tier: unverified
build_id: sha256:cc6fd9ac5f72207d4365ecbda63d87d1b64f99e05519b358a45b9f5d9bfd6f8f
dirty: true
ksor_version: 0.0.60
---

**Reference.** *How today's products realize the chapter's ideas. Skim it now, and come back when you choose a runtime or port the extraction step.*

**In everyday life.** You carry one phone charger to three countries. Each wall socket has a different shape, and one of them gives no sign of whether it has power. So you carry an adapter for each socket. You also look at the phone's screen every time, because a plug that fits tells you nothing about whether the phone is charging. In this concept, the sockets are three APIs, and the look at the screen is the check in your own code.

**What you will learn.** You practice this in Lab 25, Task 5.

- How sure is each claim?
- What does each product do with a schema, and with an answer that is no answer?
- Which of the seven jobs does each one do?
- What must stay true on any runtime?

**Why it matters.** The three look alike in a request: each takes a schema and returns JSON. They differ in what happens when the schema cannot be met, and one kind can drop the schema without an error.

**At work.** Lab 25 ends with a port. The builder moves Brightline's extraction step to a second API, and runs the same suite and the same three saved responses against it. The three are a decline, a cut answer, and valid JSON with a wrong total. What the builder writes down is the list of what changed.

<!-- OPEN: the Lab 25 task number for the port, and whether the open-weight port is in the main path or only the advanced one, are not fixed in the spec. -->

### How sure is each claim?

**Every fact here is documented, and none has been tried in a lab run yet.**

| Label | Means |
| --- | --- |
| *Documented* | Read on the product owner's own pages on November 29, 2026. A fact with no label is documented |
| *Not yet tested* | Documented, but no lab run has tried it yet |

No vendor-neutral standard defines structured output, so this section compares each product with the seven jobs.

### What does each product do with a schema, and with an answer that is no answer?

**Each takes a schema and returns JSON, and each reports a decline and a cut answer in its own place.**

**Anthropic: the Messages API.** The application writes the system prompt, and it outranks the user turn. A schema goes in `output_config.format` on any model, and the JSON comes back in a text block. Managed Agents has no structured outputs, which is why Brightline's extraction is a Messages API call.[^anthropic-structured-outputs] A decline is a 200 with the stop reason `refusal`, and a cut answer has `max_tokens`.[^anthropic-stop-reasons] Server-side fallback, in beta, passes a declined request to another model and names it in `model`.[^anthropic-refusals-and-fallback] Two of Anthropic's other tools hold a schema in a different way. Claude Code's `--json-schema` option leaves the `structured_output` field out when a run ends without valid output. So a script checks that the field is present.[^claude-code-headless] The Agent SDK checks the answer against the schema after it is written, and asks the model again on a mismatch.[^agent-sdk-structured-outputs]

<!-- EDITOR: the line that Managed Agents has no structured outputs stays here as well as in 25.7, because 25.11 is the look-up table and quiz item 25.11-07 rests on it. The other option: cut it here and point to 25.7. -->

**OpenAI: the Responses API.** The application writes `developer` messages, which are prioritized ahead of `user` messages.[^openai-text-generation] A strict schema goes in `text.format`. Every field must be required. A field that may be empty is written as a union with `null`, which means its type is written as the value or `null`.[^openai-structured-outputs] Strict schemas here accept number ranges such as `minimum` and `maximum`, which Claude's API rejects.[^openai-structured-outputs] A decline arrives as a `refusal` item in the content. A cut answer has the status `incomplete`, with the reason `max_output_tokens`.[^openai-structured-outputs] OpenAI's own page says the application "still needs to handle refusals, incomplete responses, and API errors, and validate any business rules that the schema does not express."[^openai-structured-outputs] Its prompts now live in your code too (25.1).

**Open source: an open-weight model behind a compatible endpoint.** An open-weight model is one whose trained file you can download and run on your own server. A compatible endpoint is a server that accepts the same requests as OpenAI's API. Servers such as Ollama, llama.cpp and LM Studio accept a JSON schema, and each can hold the answer to it while the model writes.[^ollama-structured-outputs][^llamacpp-grammars][^lmstudio-structured-output] The risk is silence. The guide for llama.cpp says that schema features it does not support "are skipped silently". It also says that the model never sees the schema, so the prompt must describe it too.[^llamacpp-grammars] Ollama's cloud service does not support structured outputs at all.[^ollama-structured-outputs] LM Studio warns that not every model can do it, and small models least of all.[^lmstudio-structured-output] *Running it safely.* Treat every answer from such an endpoint as free text until your own schema has passed it. Run the three saved responses against the endpoint before you trust it with live invoices.

### Which of the seven jobs does each one do?

**The two AI vendors' APIs rank who is speaking, hold a schema and report why they stopped. An open-weight endpoint may. None does jobs 3, 6 or 7.**

| The job a person did | Claude Messages API | OpenAI Responses API | An open-weight endpoint | Your code, on all three |
| --- | --- | --- | --- | --- |
| 1. Knew the form they wanted | Reads your prompt | Reads your prompt | Reads your prompt, which must also describe the schema | The prompt's words and examples |
| 2. Knew who was speaking | `system` outranks `user` | `developer` outranks `user` | Depends on the model | Which text goes where, and marking the invoice as data |
| 3. Re-read after a change | No | No | No | The versioned prompt file and the suite |
| 4. Coped with any layout | Holds the schema. Rejects ranges with a 400 | Holds a strict schema. Every field required | May hold it, or drop it with no error | Its own schema, run on every answer |
| 5. Saw a non-answer, and who answered | The stop reason, and `model` | A `refusal` item, a status of `incomplete` | Varies by server | Reading it first, before any parse |
| 6. Knew a wrong value | No | No | No | The value checks against the record |
| 7. Asked someone when unsure | No | No | No | `needs_review`, and the count by gate |

Three rows should change a decision. Row 4 decides how much your own schema check must do. It does a little on the two AI vendors' APIs, and everything on a server that may drop the schema. Row 5 decides what your first gate reads, because each API reports why it stopped in a different place. Row 2 decides which role your application writes its rules in.

### What must stay true on any runtime?

**The validator and the regression case live in the reader's code.** No API on this page checks a value against Brightline's tables, re-runs the suite after a prompt change, or sends an answer to Ana. Jobs 3, 6 and 7 are yours on every runtime, and so is the prompt file. An API can hold the shape and report why it stopped. Whether the answer is true, and what happens when it is not, stay with you.

**The operating rule:** on any runtime, the validator and the regression case live in your own code.

**Exam note.** Version 1.1 of the guide for the Claude developer foundations exam (CCDV-F), effective December 7, 2026, tests prompt revision, and structured output and defensive parsing. The exam examines Claude, not OpenAI or open-weight models.

**Do this now.** In the table above, find the column for the runtime you use. For each of jobs 4 and 5, copy this line:

> Show me the line in this project that does this job, or tell me that no line does. Change nothing.

Mark each job your code does not yet do.

[^anthropic-structured-outputs]: Structured outputs, Anthropic.
[^anthropic-stop-reasons]: Stop reasons and fallback, Anthropic.
[^anthropic-refusals-and-fallback]: Refusals and fallback, Anthropic.
[^claude-code-headless]: Run Claude Code programmatically, Anthropic.
[^agent-sdk-structured-outputs]: Get structured output from agents, Anthropic.
[^openai-text-generation]: Text generation, OpenAI.
[^openai-structured-outputs]: Structured model outputs, OpenAI.
[^ollama-structured-outputs]: Structured outputs, Ollama.
[^llamacpp-grammars]: GBNF guide: JSON Schemas to GBNF, llama.cpp.
[^lmstudio-structured-output]: Structured output, LM Studio.
