Phase 6: Prompt Engineering & GenAI Feature Design · 45 min · JSON schema · Tool/function calling · Structured outputs
Structured Outputs & Tool Calling
A free-text output is a suggestion. A structured output with a validated schema is a contract your product can actually build on.
Hiring signal: Structured outputs and tool calling are the mechanism behind nearly every production AI feature that does more than chat -- form-filling, agent-calls-API patterns, anything feeding a downstream system. A PM who can't explain what happens when a schema validation fails, and who owns the fallback, is proposing a feature with an undefined failure mode -- exactly the kind of gap a technical interviewer is trained to probe.
What you will learn
- Explain the product difference between free-text generation and schema-constrained structured output
- Explain tool/function calling at a level sufficient to design an agent-calls-API product pattern
- Identify where structured outputs unlock better UX (form-filling, downstream automation) versus where they add unnecessary rigidity
- Specify what should happen when schema validation fails, and who owns that fallback
The Problem
A PM specs an AI feature that extracts trip details (destination, dates, budget) from a free-text travel request and auto-fills a booking form. The first version asks the model to "return the destination, dates, and budget" in prose, and engineering writes a regex-based parser to pull the fields back out. It breaks constantly — the model writes "around $2,000" one time and "$2,000 (approx)" another, dates come back as "next Friday" without a resolved calendar date, and the parser silently drops fields it can't match. The PM assumed this was a model-quality problem. It's actually a product-architecture problem: free text was never going to reliably feed a form.
The fix is structured output: constraining the model to return data in a predefined, machine-parseable schema (typically JSON matching a JSON Schema definition) instead of free text a downstream system then has to guess how to parse.
Structured Outputs: What Changed and Why It Matters to Product
Modern model APIs support schema-constrained generation — the caller supplies a JSON Schema (field names, types, required fields, enums for constrained choices), and the model's output is validated against that schema, often with the provider guaranteeing the output will parse as valid JSON matching the schema. This converts "the model wrote something resembling structured data most of the time" into "the model wrote data your code can json.loads() and trust the shape of, or the call fails explicitly instead of silently returning malformed prose."
The product implications are direct:
- Form-filling UX becomes reliable enough to auto-populate a real form (like the travel-booking example) instead of requiring a human to manually re-type what an AI already extracted — which is often the actual point of the feature.
- Anything feeding a downstream system (a database write, an API call, another model's input) needs structured output, because free text forces a fragile parsing step between the model and the system that actually depends on the data being correct.
- Constrained choice fields (enums) reduce a whole category of failure — asking the model to classify a support ticket into one of six defined categories via an enum field is far more reliable than asking it to "say what category this is" in prose and hoping the wording matches your six category names exactly.
Structured output narrows what can go wrong, it doesn't eliminate errors
A validated JSON schema guarantees shape (the right fields, the right types), not correctness (the right values). A trip-extraction feature can return a perfectly schema-valid JSON object with a hallucinated destination -- the schema validator will accept it happily, because "Springfield" is a syntactically valid string regardless of whether the user actually said Springfield. Structured output eliminates the parsing-failure category of bug and does nothing for the faithfulness category from Phase 5 -- both are still needed, doing different jobs.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers Tool Calling: The Agent-Calls-API Pattern, JSON Schema Reliability and Failure Handling, Reading the Signal in an Interview, Build It, What to Practice — plus a hands-on lab, quiz, and project artifact.
Create a free account to unlock Phase 0 and Phase 1 of every course — no credit card.
Browse all courses · View pricing · DeVenture Academy