What problem does it solve?
Instructor helps you reliably extract structured information from LLM responses while enforcing a schema, catching invalid outputs early, and automatically retrying until the result conforms to your Pydantic model.
Core Features & Use Cases
- Validated structured outputs with Pydantic: Define a response model (types, constraints, enums, nested objects) and have Instructor validate the model output for you.
- Automatic retries on validation failures: When extraction fails (missing fields, invalid formats, constraint violations), Instructor feeds validation errors back to the LLM and retries.
- Robust parsing for complex JSON and typing: Safely handle nested structures, optional fields, and strict constraints so downstream code can trust the result.
- Streaming partial results: Receive partial objects during generation to power responsive UIs or incremental pipelines.
- Multi-provider support: Use consistent structured-output patterns across supported LLM providers (e.g., Anthropic and OpenAI).
Quick Start
Use the instructor skill to extract and validate a JSON object from an LLM by specifying your Pydantic model as the response_model for the request.