Lesson 8 · 16 min
Capstone: a type-safe LLM API in production
Build a complete contract-intelligence endpoint: schema, extraction with retries, streaming, and a golden-dataset accuracy gate.
What we're building
A contract-intelligence endpoint that extracts structured data from legal contracts. This is the canonical structured-output use case: deterministic schema, real downstream consequences if wrong, high value per extraction.
Requirements:
- Accept raw contract text via POST
- Return structured JSON: parties, effective date, termination clauses, governing law
- Validate every field — reject partial output
- Retry up to 3 times on validation failure
- Pass a golden-dataset accuracy test at ≥ 85%