Back to library

🧱Understand Structured Output and Function Calling

Stop bolting regex onto markdown-wrapped near-JSON. Compare prompt-asks, JSON mode, and schema-constrained decoding head-to-head, then write a strict schema for one of your real LLM outputs and test it for compliance.

Applied14 drops~2-week path Β· 5–8 min/daytechnology

Phase 1Why Text Outputs Break and What Structure Fixes

See why text outputs break and what structure fixes

4 drops
  1. A 'JSON' string is not a contract

    6 min

    A 'JSON' string is not a contract

  2. The five ways prompt-only JSON breaks

    6 min

    The five ways prompt-only JSON breaks

  3. Structure isn't a format β€” it's a constraint at decode time

    6 min

    Structure isn't a format β€” it's a constraint at decode time

  4. A schema is the API contract you wish you'd written first

    7 min

    A schema is the API contract you wish you'd written first

Phase 2Three Ways to Get the Same JSON

Get the same answer three ways and compare failures

5 drops
  1. Pure prompting is the baseline you measure against

    7 min

    Pure prompting is the baseline you measure against

  2. JSON mode kills the parsing bugs and only the parsing bugs

    6 min

    JSON mode kills the parsing bugs and only the parsing bugs

  3. Schema-constrained decoding makes invalid output literally impossible

    7 min

    Schema-constrained decoding makes invalid output literally impossible

  4. Three layers, one shape, three different failure surfaces

    7 min

    Three layers, one shape, three different failure surfaces

  5. When the parser stops failing, the prompt starts failing differently

    7 min

    When the parser stops failing, the prompt starts failing differently

Phase 3Constrained Decoding and Function Calling

Connect constrained decoding and function calling end to end

4 drops
  1. A scenario: the decoder mid-token, deciding what's allowed next

    7 min

    A scenario: the decoder mid-token, deciding what's allowed next

  2. A scenario: which tool, which args, which schema

    7 min

    A scenario: which tool, which args, which schema

  3. A scenario: the over-strict schema that ships less reliable code

    7 min

    A scenario: the over-strict schema that ships less reliable code

  4. A scenario: the eval that catches what the schema can't

    7 min

    A scenario: the eval that catches what the schema can't

Phase 4Write a Strict Schema for Your Real Output

Write a strict schema for your real output and test it

1 drop
  1. Define a strict schema for one real LLM output and test it

    8 min

    Define a strict schema for one real LLM output and test it

Frequently asked questions

What is structured output in LLMs?
This is covered in the β€œUnderstand Structured Output and Function Calling” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
How is JSON mode different from schema-constrained decoding?
This is covered in the β€œUnderstand Structured Output and Function Calling” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Why does asking for JSON in a prompt still return markdown-wrapped JSON?
This is covered in the β€œUnderstand Structured Output and Function Calling” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
What is function calling and how does it relate to structured output?
This is covered in the β€œUnderstand Structured Output and Function Calling” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
How do I test an LLM output against a JSON Schema?
This is covered in the β€œUnderstand Structured Output and Function Calling” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.