Project 03 of ai-dojo. Compare three structured-output techniques on a market-research questionnaire extraction task.
- Prompted JSON — plain prompt + schema dump, parse + retry
- Tool use — Anthropic
toolswithtool_choice, parse fromtool_useblock - Strict tool use — Anthropic tool with full JSON schema + forced
tool_choice, the closest analogue to OpenAI's strictjson_schemaresponse_format
Python 3.14 · uv · Pydantic v2 · instructor · anthropic · pytest · rich
Model: claude-haiku-4-5-20251001 (Anthropic only — OpenAI dropped).
src/structured_output/ # package
tests/ # pytest
fixtures/briefs/ # hand-written research briefs (*.md)
runs/ # sweep artifacts (JSON, gitignored)
notes/ # technique comparison writeup
uv sync
cp .env.example .env # fill ANTHROPIC_API_KEYuv run extract --brief fixtures/briefs/01-coffee-subscription.md --technique tool_use
uv run sweep --briefs fixtures/briefs/ --out runs/See project brief.