What problem does it solve?
Extracting structured fields from LLM outputs is often brittle: JSON can be malformed, required fields can be missing, and types don’t reliably match what your app expects.
Core Features & Use Cases
- Pydantic-validated structured outputs: Enforce schemas (types, constraints, enums) so you get reliable, typed data for downstream logic.
- Automatic retry on validation failures: When extraction fails, the library feeds validation errors back to the model and re-attempts until it succeeds (configurable retries).
- Safe, type-aware parsing for complex JSON: Handle nested models, optional fields, and constrained values with consistent structure.
- Streaming partial results: Process incremental outputs in real time for faster UX and incremental pipelines.
- Multi-provider support: Work across OpenAI and Anthropic with consistent response handling.
Quick Start
Use instructor to extract a Pydantic model from a messy LLM response, automatically retrying until the output matches your schema.