Instructor
A Python library that wraps LLM APIs and guarantees structured outputs (JSON, dataclasses, Pydantic models) by validating and retrying.
Think of it like
A typesafe layer on top of LLM completion—ask for an object, get an object or an error.
Example
Define a Pydantic model for a customer record. Call instructor.create(model=Customer, prompt='Extract customer from this email'). Get a fully-validated Customer object or a retry loop.
How it actually works
Instructor patches OpenAI/Anthropic SDKs to add a `response_model` parameter. It uses the schema to prompt the model, validates the output, and retries if validation fails. You don't write parsing logic; you just define the schema. Massively reduces boilerplate for structured extraction.
For product teams
Turns schema validation into a no-brainer for structured tasks; cuts downstream data bugs.
For engineers
Pydantic-native; patches LLM SDKs; automatic retry with backoff.
Read anything AI without the jargon
Look up any term in plain English, or save terms as you read with the free Chrome extension.
Open DecoderAdd to Chrome