Most popular Python library for getting structured, validated outputs from LLMs by combining pydantic schemas with provider-native function calling.
Most popular Python library for getting structured, validated outputs from LLMs by combining pydantic schemas with provider-native function calling.
Instructor is the open-source pydantic-based library for structured LLM outputs with automatic retries, streaming, and support for OpenAI, Anthropic, Gemini, and 10+ other providers.
Instructor is the gold standard for structured LLM output extraction, with 3M+ monthly downloads and support for 15+ providers. Using Pydantic models for validation and automatic retry logic, it turns unreliable LLM text into guaranteed typed Python objects. Essential for any production system that needs reliable, structured responses from LLMs.
Define output structure as Pydantic models with typed fields, descriptions, and validators. Instructor converts these to function-calling schemas and returns validated Python objects automatically.
When Pydantic validation fails, Instructor provides specific error messages to the LLM and retries. Models receive context about validation failures and can self-correct, achieving 99%+ success rates.
Unified from_provider() interface works with OpenAI, Anthropic, Google, Cohere, Mistral, DeepSeek, Ollama, and 10+ more providers. Switch providers without code changes for easy A/B testing and cost optimization.
Get incremental Pydantic model updates as the LLM generates tokens. Fields populate progressively, enabling real-time UIs that show structured data appearing as extraction progresses.
TOOLS mode uses native function calling for maximum reliability, JSON mode forces JSON output for weaker models, MD_JSON extracts from markdown blocks, and PARALLEL extracts multiple objects simultaneously.
Use Union types to let the LLM select the appropriate Pydantic model for classification tasks. Supports discriminated unions and automatic routing based on input content analysis.
Free (MIT)
Ready to get started with Instructor?
View Pricing Options →Instructor works with these platforms and services:
We believe in transparent reviews. Here's what Instructor doesn't handle well:
Instructor has continued expanding beyond Python in 2025 and into 2026, with official ports for TypeScript, Go, Elixir, PHP, and Ruby reaching broader provider coverage. The Python library has standardized on a from_provider entry point that unifies client instantiation across OpenAI, Anthropic, Gemini, Mistral, Cohere, Groq, Together, Fireworks, Ollama, and vLLM, and has added first-class support for newer provider features such as OpenAI Structured Outputs, Anthropic tool use refinements, and Gemini's structured generation modes. The documentation has been reorganized around a learning track, integrations catalog, cookbook, and concepts guide, and the hooks API has matured into the recommended path for observability and tracing integrations.
AI Agent Builders
Grammar-constrained generation for deterministic model outputs.
AI Frameworks
Guidance review 2026: token-level constrained LLM generation with grammars, regex, and JSON schema — MIT open source — features, pros, cons, use cases.
Pricing and features change often. If anything on this Instructor page is wrong or missing, tell us and include a link to the source. We review every correction.