LLM application development

Get reliable structured outputs from LLMs

JSON schemas, function schemas, validation with Pydantic/Zod, handling malformed outputs.

~6 focused hours·beginner

Tools: Pydantic, JSON Schema, OpenAI structured outputs / function calling, Anthropic tool use, instructor

Market relevance — share of job ads asking for this
What employers mean

You should be able to…

  1. Define a JSON schema/Pydantic model and force the LLM to return data matching it
  2. Use function/tool calling to extract structured fields from unstructured text (invoices, resumes, tickets)
  3. Validate and repair malformed LLM JSON output before it hits downstream code
  4. Handle nested/optional fields and enums in extraction schemas
  5. Fall back gracefully when the model returns invalid structure (retry, default, or flag for review)
  6. Chain structured extraction with a database write or API call

Needs first: Integrate LLM APIs into an application

Learn — free, link-checked

The few resources that matter

Read · beginner · 40 min · docs.pydantic.dev

Pydantic Documentation

Pydantic is the de facto schema/validation layer paired with every Python LLM structured-output pipeline. — Pydantic
Read · intermediate · 30 min · platform.openai.com

Structured Outputs

Explains JSON-schema-constrained generation directly from the provider that popularized the strict-schema approach. — OpenAI
Read · intermediate · 30 min · python.useinstructor.com

Instructor: Structured Outputs for LLMs

The most widely used library for getting validated Pydantic objects out of any LLM with automatic retries on bad output. — Jason Liu / instructor
Read · intermediate · 35 min · docs.anthropic.com

Tool Use (Function Calling) with Claude

Canonical reference for defining tool schemas and getting reliable structured calls back from Claude. — Anthropic
Practice

Field extractor for Indian GST invoices

Build a pipeline that takes messy Indian GST invoice text (varying formats, GSTIN, HSN codes, CGST/SGST splits) and extracts a strict Pydantic schema (vendor, GSTIN, line items, tax breakup, total) using structured outputs. Include a validation layer that flags invoices where the extracted tax math doesn't add up.

Done when
  • Pydantic schema enforces types (GSTIN pattern, decimal amounts) and rejects invalid extractions
  • At least 15 varied sample invoices (different formats/vendors) processed with over 90% field accuracy
  • A validation check flags cases where CGST+SGST+line totals don't reconcile with the invoice total
  • Malformed model output triggers one retry with an error-correction prompt before failing loudly
Prove it

Evidence a recruiter can check

  • Public GitHub repo with the Pydantic schema, sample invoices (redacted/synthetic), and extraction accuracy on a test set
  • A validation-failure log showing the reconciliation check catching a real bad extraction
  • README documenting the retry/repair strategy for malformed outputs
  • A short demo video or notebook run showing end-to-end extraction
Interview

Questions you'll get asked

  1. How do you guarantee an LLM response is valid JSON your backend can parse without crashing?
  2. What's the difference between JSON mode, function calling, and Pydantic-based structured outputs?
  3. How do you handle a field the model hallucinates that isn't in your schema?
  4. Walk me through extracting structured data (amount, date, vendor) from a scanned invoice using an LLM.
  5. How would you validate and auto-correct a malformed LLM output in a production pipeline?
  6. How do you design a schema so the model doesn't have to guess formats (dates, currency) inconsistently?
See where you stand for Prompt Engineer / AI Workflow Specialist