prompt-eng

Structured Output

Structured output is an LLM API capability that constrains generation to conform to a developer-supplied schema — most commonly JSON Schema — guaranteeing not just syntactically valid output (as with basic JSON mode) but output that matches exact field names, types, required fields, enums, and nesting structure. It is typically implemented under the hood via constrained decoding (the model's token-generation process is restricted at each step to only tokens that keep the output schema-valid) or via the same mechanism that powers tool calling/function calling, where the "tool" being called is really just a schema definition for the desired response shape rather than an actual executable function. Anthropic, OpenAI, and Google all offer some form of this (Claude and OpenAI via tool-use/function-calling-based structured output with a strict mode; Gemini via responseSchema), and it has become one of the most important reliability primitives for production LLM applications because it eliminates an entire category of integration bugs at the API layer rather than requiring application-side validation-and-retry logic. For SaaS builders, structured output is the difference between "the AI feature works 97% of the time and needs a fallback path for the other 3%" and "the AI feature is guaranteed schema-conformant every time," which matters enormously for anything writing to a database, populating a typed UI component, or feeding a downstream automated pipeline (the kind of no-code/low-code workflow automation tools like Make.com or Zapier are built around). Design considerations include keeping schemas as simple as reasonably possible (deeply nested or very large schemas can still degrade model output quality even under constrained decoding), using enums wherever a field has a known finite set of values (dramatically improving consistency over free-text fields), and adding a description to each schema field, since providers generally use these descriptions to guide what the model should put there — the schema itself becomes part of the effective prompt. Concrete worked example: a lead-qualification SaaS tool defines this schema for its AI call-summary feature: {"lead_score": integer (1-100), "next_action": enum["schedule_demo", "send_pricing", "nurture", "disqualify"], "key_objections": array of strings, "summary": string (max 200 chars)}. Every call transcript processed through this schema-constrained endpoint returns a response the CRM can insert directly into typed database columns with zero parsing logic and zero risk of an invalid next_action value ever reaching the sales pipeline — the enum constraint makes an out-of-vocabulary value structurally impossible, not just unlikely.

Related terms

More Prompt Engineering terms