Instructor layers Pydantic-style schemas onto LLM APIs so responses parse into typed models with retries, streaming, and nested fields.
Overview
Instructor targets developers who need reliable structured data from language models instead of hand-parsed JSON. You define models describing the desired fields, call a unified client interface, and receive validated objects with IDE-friendly typing. The project builds on Pydantic for validation and exposes parallel implementations in Python, TypeScript, Ruby, Go, Rust, and Elixir according to its documentation.
The client helpers wrap numerous providers—including OpenAI, Anthropic, Google, Mistral, Cohere, Ollama, and DeepSeek—so the same schema-first code can switch models via configuration. When validation fails, built-in retry logic can re-ask the model with error context, and streaming APIs emit partial structures as tokens arrive.
Complex nested lists, enums, and custom field validators are supported, which suits extraction pipelines for support tickets, entities in text, or other domain objects. The maintainers position Instructor for focused extraction workloads, noting that PydanticAI extends similar models when teams need fuller agent runtimes, observability, and evaluation tooling.
Install paths cover common Python package managers, and cookbooks document provider-specific examples alongside CLI helpers that open documentation in a browser for quick reference during development.
Key features
- Pydantic model response binding
- Automatic validation retries
- Streaming partial object support
- Nested schema extraction
- Multi-provider client factory
- Python TypeScript Ruby Go Rust ports
- Local models via Ollama integration
- Complex field validators
Use cases
- Structured data extraction from text
- Typed LLM API responses
- Entity parsing in backends
- Validated JSON from chat models
- Cross-provider model swapping