instructor: Extract Validated Structured Data from LLMs

Summary
Instructor turns LLM responses into validated, typed Python objects using Pydantic models. It is useful for applications that need dependable extraction across providers, with retries and streaming handled through a consistent API.
At a glance
- Language
- Python
- License
- MIT
- Stars
- 14k
- Forks
- 1.3k
- Added to OSRepos
- November 8, 2025
- Last analyzed
- October 3, 2026
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Overview
Instructor is a Python library for requesting structured data from large language models and validating the result against Pydantic models. It addresses the gap between free-form model responses and application code that expects typed, schema-conforming values.
It suits developers building extraction or classification workflows who want provider flexibility and less custom response parsing. Its focus is schema-first structured outputs rather than general-purpose agent orchestration.
Key Features
- Define desired output with Pydantic models and receive validated, typed objects.
- Use a consistent client interface across supported providers, including OpenAI, Anthropic, Google, Ollama, and Groq.
- Retry responses when validation fails, with configurable retry limits.
- Stream partial objects while a response is being generated.
- Represent nested data structures using model fields.
- Configure provider API keys directly or through environment variables.
Use Cases
- Data extraction: Turn emails, documents, or user messages into typed records for downstream processing.
- Classification pipelines: Return validated categories and attributes instead of parsing free-form text.
- Form and record enrichment: Populate nested application data from natural-language input, with validation constraints.
- Incremental user interfaces: Show partially extracted fields as they arrive through streaming.
- Provider-flexible applications: Keep a schema-oriented calling pattern when trying supported model providers.
Project Facts
- Language: Python
- License: MIT
- Stars: 14k
- Forks: 1.3k
- Topics: openai, openai-function-calli, openai-functions, pydantic-v2, python, validation
- Archived: No
Getting Started
Install with:
pip install instructor
See the README and Python documentation for provider setup and usage details.
Considerations
- This is a Python library and requires using a supported model provider or configuring a local provider such as Ollama.
- Structured results depend on model responses and provider capabilities. Validation and retries help handle failures, but do not guarantee that extracted information is factually correct.
- The project focuses on structured outputs. Applications needing broader agent workflows may want a dedicated agent framework.
- The repository has 136 open issues, so review current issues and documentation when evaluating fit.
Found this useful?
Share it with someone who would like instructor.
Comparisons
Source repository
Open the original repository on GitHub.
25 counted GitHub visits
Related repositories
Similar repositories that may be relevant next.

agentevals: Evaluate AI Agents from OpenTelemetry Traces
October 4, 2026
agentevals scores AI agent behavior from existing OpenTelemetry traces, without rerunning agents or making extra model calls. It suits teams building instrumented agents that need local evaluation, golden-set checks, or CI quality gates.

web-design: Create Consistent Web Pages with a Claude Code Skill
October 3, 2026
web-design is a Claude Code skill that turns product briefs, reference URLs, or screenshots into an editable design specification before generating web code. It is suited to developers and designers who want a repeatable, spec-led workflow for building consistent pages.

oomwoo: Build a DIY Robot Vacuum
October 2, 2026
OOMWOO is a planned, hackable robot vacuum built around Raspberry Pi, ROS2 and 2D LiDAR. It is aimed at makers who want to build and customize a locally controlled vacuum, but its hardware and build instructions are still in development.

shepherd: Supervise Agents with Reversible Execution Traces
October 2, 2026
Shepherd records agent work as inspectable, reversible execution traces and keeps changes as proposals for review. It is aimed at developers building systems that supervise, replay, or manage the work of other agents.