PythonCoreApplied AI EngineerForward Deployed EngineerApplied AI Architect
Structured extraction to validated Pydantic objects
Extract invoices from text or PDF with structured outputs, then validate, check business rules and grounding, retry once with feedback, and run it all as a Message Batch.
Locked
The code is part of the full course
The file map and notes are open to everyone. Get lifetime access to every template's source, the .zip download and all four tracks for a one-time $249.
Run it
shell
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # add ANTHROPIC_API_KEY
python -m app.main check samples/invoice_acme.txt samples/invoice_acme.expected.json # offline
python -m app.main extract samples/invoice_acme.txt
python -m app.main extract samples/invoice_bad_totals.txt # needs_review
python -m app.main batch-submit samples/*.txt
python -m app.main batch-collect <batch_id>Test it
shell
pytest -qOffline: no API key or network needed.
Taught in
- Module 2 Structured Outputs: Turning Messy Notes into Data with Claude
- Module 2 Exercise: Extract Requirements from Call Notes with Claude
- C2 Tool Use and Structured Outputs
- E1 Exercise: A Warranty-Claim Extractor That Checks Its Own Output
- E1 Structured Outputs and Validation in Depth
- E9 Documents and Images as Input
- E9 Exercise: Purchase-Order Intake with an Abstain Path
- E9 Throughput at Scale: Async Clients, Rate Limits and Batches
- E9 Exercise: A Message Batches Job, End to End
- A6 Reference Architecture: Document Processing and Extraction
- E6 Design It: Multimodal Document Intake for a Customs Broker