567-labs

instructor: Get Structured LLM Outputs with Pydantic

Instructor is a Python library built on Pydantic that turns LLM responses into validated, typed data. It provides a consistent schema-first interface across major model providers, with retries and streaming for extraction workflows.

ActivePythonMITAILLMLibrary
Stars
14.1k
Forks
1.3k
Stars, last 30 days
+88
Last commit
2 days ago
Contributors
100+

Our take

Activeregular commits and releases

Health score

68/100

How it is scored
Activity
77
Community
71
Issues
55
Pull requests
68

+88 stars in the last 30 days

  • More contributors than 78% of the projects we track

Instructor is a focused, actively maintained choice for Python teams that want Pydantic-validated LLM extraction without adopting a broader agent framework.

Good fit if

  • Your application is Python-based and its output schemas can be represented with Pydantic.
  • You want validation, retries, streaming, and a shared interface across model providers.
  • You prefer an MIT-licensed library with regular commits and releases and a broad contributor base.

Look elsewhere if

  • Your main need is a full agent runtime rather than schema-first extraction.
  • Your application is not Python-based, or you do not want to use Pydantic models for output definitions.
  • You need an interface outside the chat-completions pattern shown in the project documentation.
All health signals
Last commit2026-10-20 (2 days ago)
Commits, last 90 days100+
Releases, last 12 months14 (latest v1.17.0, 2026-09-09)
Contributors100+ (top contributor: 68% of commits)
Issues closed, last 90 days8+ (typically closed in 6 days)
Pull requests merged, last 90 days21 (typically merged in 0 days)
Project age3 years

Checked on 2026-10-23 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

14,121

Forks

1,386

Change since Nov 17, 2026: +5 stars·+1 forks

Overview

Instructor is a Python library built on Pydantic for getting reliable, structured outputs from large language models. You define the desired result as a Pydantic model, and Instructor handles validation and retries instead of leaving your application to parse and check raw JSON.

It is aimed at Python developers building schema-first extraction workflows. The same interface supports major model providers, so it can suit applications that need structured data from different hosted or local LLMs without writing separate extraction logic for each.

Key Features

  • Define output schemas with Pydantic models and receive validated, typed results.
  • Retry failed validations, including sending validation errors back to the model.
  • Stream partial model instances while a response is being generated.
  • Extract nested objects using regular Pydantic model structures.
  • Use a common chat-completions interface with providers including OpenAI, Anthropic, Google, Ollama, and Groq.
  • Supply API keys directly or use environment variables.

Use Cases

  • Build data extraction pipelines that turn messages, documents, or other text into application-ready records.
  • Add typed LLM responses to Python services without maintaining custom JSON parsing and validation code.
  • Stream partially extracted fields into an interface when users should see results before generation finishes.
  • Keep extraction code consistent when testing or supporting multiple LLM providers.

What you need

Detected in the repository

  • Python <4.0,>=3.9 (from pyproject.toml)
  • A test suite and automated checks on GitHub Actions

License in plain words

MITpermissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the copyright and license notice
  • Share your changes: no

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

pip install instructor

See the README and Python documentation for provider setup and usage details.

Considerations

  • The package requires Python 3.9 or newer and a version below 4.0. The project data indicates CI and tests are present.
  • Instructor helps validate generated data, but the result still depends on the model producing an answer that satisfies the schema; validation retries do not guarantee correctness.
  • The project is active, with recent commits and releases. Issue handling data shows issues are closed with a short median turnaround, though the measured number closed in the recent period is limited.
  • The MIT license permits broad reuse, subject to its license terms and notices.

Found this useful?

Share it with someone who would like instructor.