Instructor

Instructor

โ˜… 4.2 ๐Ÿ”– 100 saves ๐Ÿ’ฐ Freemium GitHub

Instructor is the most popular open-source library for getting reliable structured outputs from large language models. Built on Pydantic, it lets you declare the exact shape of data you want, a user, an invoice, a classification, and receive validated Python objects back instead of fragile raw text. The project has earned more than 14,000 stars on GitHub and is maintained actively, with updates through late 2026.

Overview

Anyone who has parsed free-form LLM output with regular expressions knows the pain Instructor removes. You define a Pydantic model, pass it as the response model, and Instructor handles prompt construction, JSON parsing, validation, and automatic retries when the model’s answer does not match the schema. Type safety and IDE support come free because results are ordinary Pydantic objects. The library works across providers, including OpenAI, Anthropic, Google, and many open-model endpoints, through a unified provider syntax, and supports streaming of partial objects so UIs can render structured data as it arrives. Beyond extraction, it covers validation hooks, nested models, enums, and data pipelines, which is why it became standard tooling for LLM applications in Python. The maintainers also point agent builders toward PydanticAI for full agent runtimes, while Instructor stays focused on doing structured output simply and cheaply.

Key Features

  • Declare Pydantic models and get validated objects back from any LLM
  • Automatic retries and error handling when outputs miss the schema
  • Works across OpenAI, Anthropic, Google, and open-model providers
  • Streaming support for partial structured responses
  • Type safety and IDE autocompletion through standard Pydantic types
  • Rich validation, nested models, and extraction patterns included
  • Minimal API: usually one parameter added to your existing client call

๐Ÿ’ณ Pricing

Instructor is completely free and open source under the MIT license. You only pay for the underlying LLM API calls you make through your chosen provider; the library itself has no tiers, keys, or usage limits.

Who Is It For

Instructor is for Python developers building anything that turns language into data: document extraction, classification pipelines, form filling, agents that call tools, and analytics over text. If your application depends on an LLM returning dependable JSON, Instructor is close to essential infrastructure.

๐Ÿš€ Visit Instructor Official Site

๐Ÿšฉ Report an issue