Skip to content
aicoolies logo
Instructor logo

Instructor

Structured LLM outputs with validation

Instructor is the most popular Python library for extracting structured, validated data from large language models, with over 3 million monthly downloads and ports across Python, TypeScript, Go, Ruby, Elixir, and Rust. It uses Pydantic models to define output schemas and automatically handles validation, retries, and error correction when the LLM output does not match. Instructor patches existing client libraries instead of replacing them, preserving full access to the underlying API.

About Instructor

Instructor is the most popular Python library for extracting structured, validated data from large language models, with over 3 million monthly downloads and support across Python, TypeScript, Go, Ruby, Elixir, and Rust. It solves the challenge of getting reliable, schema-conformant outputs from LLMs by using Pydantic models to define output schemas and automatically handling validation, retries, and error correction when the model output does not match the expected structure. Instructor provides a thin, zero-cost abstraction that patches existing LLM client libraries rather than replacing them, preserving full access to the underlying API features.

Instructor differentiates itself with automatic retry logic that feeds validation errors back to the model for self-correction, semantic validation capabilities for checking outputs against sophisticated criteria beyond simple type checking, and streaming support for processing structured data as it arrives. The library supports 15+ providers including OpenAI, Anthropic, Google Gemini, Mistral, Cohere, Ollama, and DeepSeek through a unified from_provider() interface. Recent integrations with OpenAI Responses API, comprehensive multi-modal support, and the llms.txt specification for AI-readable documentation keep Instructor at the forefront of structured output tooling.

Instructor is designed for developers and data engineers who need to extract structured information from LLM responses in production applications, from simple classification tasks to complex multi-field extraction pipelines. It integrates seamlessly with existing OpenAI, Anthropic, and other provider client libraries, making it easy to add structured output capabilities to any existing LLM workflow with minimal code changes. The library is particularly well-suited for data pipelines, content classification, entity extraction, and any use case where LLM outputs need to conform to a predefined schema with guarantees of type safety and validation.

Pricing & Platform Specs

Pricing Summary

100% free and open-source library licensed under MIT ($0). There are no subscription, platform, or licensing fees. Developers only pay for their underlying LLM provider token usage (e.g., OpenAI, Anthropic, Gemini) or $0 when running on local models via Ollama/vLLM.

full pricing breakdown →

Supported Platforms

Python, TypeScript, Ruby, Go, Elixir

Explore categories, tags & use cases

Structured generation for LLMs

Outlines is an open-source Python library for structured text generation that guarantees LLM outputs conform to a defined schema or format. It constrains the model's token selection at each step so only tokens leading to valid output are considered, eliminating fragile post-processing. Supports multiple-choice constraints, regex patterns, JSON Schema, and type-safe Pydantic models — helping teams extract reliable structured data from any LLM.

Open Source

Type-safe LLM function builder

BAML is a domain-specific language by BoundaryML for building reliable AI workflows and agents through schema engineering. It turns prompt engineering into a structured, type-safe discipline by letting developers declaratively define function schemas, validate LLM responses, and version prompts without fragile JSON parsing or boilerplate. BAML reframes prompt engineering as schema definition, making AI workflows testable and maintainable across models.

Open Source

Python agent framework by Pydantic team

Agent framework built on Pydantic for type-safe AI applications. Provides structured outputs, dependency injection, and multi-model support. Created by the Pydantic team, it brings the same validation and typing philosophy that made Pydantic essential for Python APIs to the world of AI agents, ensuring reliable data flow between LLMs and application logic.

Open Source

Community experience

Sources & verification

Sources checked
Content verified

Verification dates are editorial checks. Routine CMS saves and automatic updatedAt timestamps do not advance them.

FAQ

What is Instructor?

Instructor is the most popular Python library for extracting structured, validated data from large language models, with over 3 million monthly downloads and ports across Python, TypeScript, Go, Ruby, Elixir, and Rust. It uses Pydantic models to define output schemas and automatically handles validation, retries, and error correction when the LLM output does not match. Instructor patches existing client libraries instead of replacing them, preserving full access to the underlying API.

Is Instructor free?

Yes — Instructor is open source and free to use. 100% free and open-source library licensed under MIT ($0). There are no subscription, platform, or licensing fees. Developers only pay for their underlying LLM provider token usage (e.g., OpenAI, Anthropic, Gemini) or $0 when running on local models via Ollama/vLLM.

Is Instructor open source?

Yes — Instructor is open source.

Is Instructor still maintained?

Yes — Instructor is active. Its listing was last verified on September 6, 2026.

What are the best Instructor alternatives?

The first editor-selected Instructor alternatives are Outlines, BAML, Pydantic AI.