Prompting techniques
Structured output
Definition
Structured output means constraining a model to return data in a machine-readable shape such as JSON, usually by specifying the exact schema in the prompt or using a provider feature that enforces it.
When a program consumes model output, free text is a liability. Structured output solves this by pinning down the exact keys, types and permitted values you expect.
The most reliable approach is showing the literal schema in the prompt — models follow explicit key names far more consistently than prose descriptions. Several providers now offer schema enforcement (JSON mode, function calling, structured outputs) that guarantees valid, conforming JSON rather than merely requesting it.
Common failure modes without enforcement: markdown code fences wrapped around the JSON, trailing commas, and explanatory text before or after the object. Asking for "valid JSON only, no markdown" prevents most of them.
Example
Return JSON only, matching: {"title": string, "company": string, "salary_range": string | null, "remote": boolean}
Related terms
Function calling
Function calling lets a model request that your code run a specific function with specific arguments. You expose tool definitions; the model returns a structured call, your code executes it, and the result goes back into the conversation.
JSON Schema
JSON Schema is a standard vocabulary for describing the shape of JSON data — its keys, types and required fields. AI providers use it to constrain model output to a guaranteed structure.
Prompt chaining
Prompt chaining splits a complex task into a sequence of focused prompts, where each step's output feeds the next. Chains are easier to debug and more reliable than one large prompt.
Zero-shot prompting
Zero-shot prompting means asking a model to do a task with no worked examples — just an instruction. It works well for common tasks the model has seen extensively in training.
Few-shot prompting
Few-shot prompting means including two to five worked examples of the input-output pattern you want before making your real request. It is the fastest way to lock in a consistent format, tone or edge-case behaviour.
Chain-of-thought prompting
Chain-of-thought prompting asks a model to work through its reasoning step by step before answering. It measurably improves accuracy on maths, logic, and multi-step problems by forcing intermediate steps instead of an immediate guess.
Put this into practice
Understanding the term is step one. Our free courses and tools let you actually use it.