Why shape is a first-class requirement
The moment a prompt's output feeds anything other than human eyes - a parser, a dashboard, another prompt - format stops being cosmetic and becomes the contract. A triage answer that is 98% right but wrapped in "Sure! Here's the JSON you asked for:" is a production incident. This session covers the four levers that control output shape, the grown-up way to get reliable JSON, and the migration guide for a technique that now returns HTTP 400.
Format is part of the spec 7 min live
Before reaching for API features, know the cheap levers. Models are format mirrors: they imitate the shape of what you show them. That single fact, plus session 2's positive-instruction rule, covers most day-to-day formatting - and Gemini adds a fourth lever the other vendors underuse.
LiveThe mirror: format matching + positive spec4 min▶
Format matching is documented model behaviour, not folklore: prompts written in heavy markdown get markdown answers; prose prompts get prose. The practical consequences:
- Write the prompt in the register you want back. Want terse bullet output? Write terse bullet instructions. Want prose with no headers? Do not fill your prompt with headers.
- Your example IS the format spec. One pasted perfect output beats a paragraph of formatting adjectives - session 2's "show it, don't describe it", now aimed at shape instead of content.
- Say what TO do. "No markdown" leaves a vacuum; "write plain prose paragraphs" fills it. Same Boonstra rule as session 2, and nowhere does it matter more than format, where negations fail constantly.
Verbosity is a spec dimension too, and an unstated one is a free choice for the model. Name it in units you can check: "max 25 words", "3 bullets", "one sentence per field". (OpenAI even exposes a verbosity API parameter on newer models - the industry now treats answer length as a dial, not a vibe.)
Self-studyThe completion starter - Gemini's underrated lever2 min read▶
Google's prompting docs push a trick the other vendors barely mention: give the start of the output as a pattern and let the model complete it. End your prompt with the first line or two of the answer you want:
The model locks onto the pattern and continues it - no preamble, no format drift. It is the same instinct that made prefill popular (Part 3 tells that story), but it lives entirely in the prompt text, so it works on any vendor and nothing about it is deprecated. Cheap, effective, great for quick extraction jobs where a full schema is overkill.
Structured output, the grown-up way 8 min live
Every team goes through the same arc: beg for JSON in the prompt, celebrate that it mostly works, then meet the 2am ticket that broke the parser. The 2026 answer is native structured outputs - all three major vendors now let you attach a JSON schema to the API call and enforce the shape at generation time.
LiveSchemas are contracts with downstream code4 min▶
The division of labour that makes this reliable:
- The API guarantees the shape. Pass a JSON schema (Anthropic structured outputs, OpenAI structured outputs, Gemini
responseSchema) and valid-and-matching is enforced at generation time. No more preamble-stripping, no more regex for the closing brace. - The prompt still carries the meaning. A schema can force
"priority"to be one of P1/P2/P3; it cannot know that an angry customer with a payment issue is a P1. Field semantics, edge-case policy, and examples stay in the prompt - everything session 2 taught still applies. - The schema is a real interface. Version it, review it, and treat a schema change like an API change - because the dashboard, the router, and the downstream prompt all consume it. Prompts-as-code gets its full treatment in sessions 8-10; the schema is where it starts being literal.
The classic failure the contract kills: the model answers "Sure! Here's the classification: {"category": ...}". Perfectly helpful, perfectly unparseable. With a schema attached there is no preamble to strip - the friendly wrapper simply cannot exist in the output.
Self-studyJSON honesty: output format ≠ input wrapper2 min read▶
Session 2's delimiter ranking (GPT-4.1 guide, measured) put JSON worst for wrapping long documents in the input - the escaping noise drowns the signal. Hold both facts at once, because they confuse teams constantly:
| Direction | JSON verdict | Why |
|---|---|---|
| Model output | Excellent - with a schema | Machines consume it; structured outputs make it guaranteed |
| Long-document input | Worst of the delimiters | Every quote escaped, every newline literal - signal drowns |
So the well-dressed production prompt often looks asymmetric on purpose: markdown or XML walls around the input (session 2), a strict JSON schema on the output (today). That asymmetry is correct, not messy.
Prefill is dead - here is what replaced it 7 min live
For two years, the classic Claude answer to output control was prefill: start the assistant's turn yourself (with {, or a skipped preamble) and the model continues from there. It was clever, it was everywhere - and on Claude 4.6 and newer, a prefilled assistant turn returns a 400 error. Not discouraged. Rejected.
LiveThe 400 error, and the honest flag on the tutorial3 min▶
Three facts to keep straight, because the internet has not caught up:
- The break is hard. On Claude >= 4.6, sending a partial assistant message to continue from fails the request with a 400. Code that prefills does not degrade - it stops working.
- The official tutorial still teaches it. Anthropic's interactive tutorial chapter 5 - the canonical output-formatting chapter - demonstrates prefill. Treat that chapter as history: the concepts (the model continues from what exists) remain instructive, the technique is legacy. This course flags it so you do not learn a 400 by hand.
- Anthropic published the migration path. The current best-practices docs name five replacement patterns, one per job prefill used to do. That is the table below - bookmark it, because you will meet prefill in old codebases and Stack Overflow answers for years.
LiveThe five migration patterns - old trick to new pattern4 min▶
Every prefill in the wild was doing one of five jobs. Here is each job's 2026 replacement:
| Old prefill trick | New pattern | How |
|---|---|---|
Prefill { to force JSON | Structured outputs | Schema in the API call - shape enforced, not coaxed |
| Prefill past "Certainly! Here is..." | No-preamble instructions | "Output only the JSON object, with no preamble or commentary" |
| Prefill to steer past hedging or refusal-ish openers | Refusal steering | System-prompt instructions defining what to do when unsure, instead of scripting the opener |
| Prefill half a draft for the model to continue | Continuations via user turn | Put the partial text in the user message: "continue from the last line" |
| Prefill fake dialogue to seed state or persona | Context hydration | State prior context explicitly in system/user content - no ventriloquism |
Notice the completion starter from Part 1 is the prompt-level cousin of pattern 4: the pattern lives in the user turn, the model owns its whole reply, every vendor is happy.
TriageBot v2: the JSON contract ★ 18 min · laptops open
Session 2 left TriageBot v1 structured and exampled, answering in two prose lines. Today it grows an interface: a strict JSON contract that Meridian's routing code can consume - category, priority, summary, suggested owner, confidence. v1's UNSURE escape hatch grows up into OTHER with a reason. First, the road most teams take - so you recognise it:
Define the contract first. Write the schema block before touching the prose: fields, allowed values, when each is required. Deciding P1/P2/P3 semantics IS the design work - the JSON is just its notation.
Port v1 into the contract. Keep the data/instruction wall and the WHY-motivated rules from session 2; swap the two-line output format for the schema. Note rule 2 doing the no-preamble pattern from Part 3's table.
Add the two examples. One clean case, one OTHER case - the fallback rule teaches best by example, exactly like v1's UNSURE did. Examples double as format matching: the model mirrors their compact one-line JSON.
Break it on purpose. Feed it the weird ticket: "URGENT!!! my order #99 arrived broken AND you charged me twice AND I want a refund AND compensation". Two categories, real anger. Does it pick one and report low confidence, or go OTHER? Does the summary stay under 25 words? Whatever leaks, tighten the rule that should have caught it.
Cash in the API guarantee. If your vendor account allows, re-run with the schema passed as a native structured-outputs parameter and delete rule 2. Prompt carries meaning, API carries shape - the asymmetry from Part 2, now in your own code.
Three things before session 4 ◐ 25 min total
- Contract one real prompt. Take a work prompt whose output anything parses, give it a schema (prompt-level or native), and run 10 real inputs through before and after. Count parse failures - that pair of numbers is your first output-reliability eval.
- Hunt prefill in the wild. Search your team's prompt code for prefilled assistant turns. Migrate one using the five-pattern table, and leave a comment linking the pattern - future readers will hit the 400 otherwise.
- Try the completion starter on a quick extraction task (Gemini if you have it - the trick is portable). Note whether the pattern held for 10 inputs, and where you would upgrade to a schema instead.
What this session covers
Builder-level coverage of the sources below. Official certificates, videos, and quizzes stay with the vendors - links live in the course map.
Three questions before you go 🎯 ◐ 90 seconds
1 · On Claude 4.6 and newer, prefilling the assistant's turn (e.g. starting it with "{")...
The break is hard: prefilled assistant turns fail the request outright on Claude >= 4.6. The tutorial's chapter 5 still shows the old trick - teach it to yourself as history, and reach for the five migration patterns instead.
2 · Per the GPT-4.1 guide's measured delimiter ranking, wrapping a long document in JSON on the input side is...
JSON is measurably the worst input wrapper for long documents, and excellent as a schema-enforced output format. The asymmetric prompt - markdown/XML walls in, JSON contract out - is correct by design.
3 · You used to prefill "{" to force JSON output. The 2026 replacement is...
Begging harder is road 1 with extra exclamation marks, and sampling knobs never guaranteed shape (some current models reject them anyway). The schema-in-the-call contract is the named migration pattern - guaranteed, on all three vendors.