Instructor is an open-source tool focused on providing structured output for large language models (LLMs), designed to help developers obtain reliable JSON data from any mainstream LLM. Built on Pydantic, it provides data validation, type safety, and IDE support. Users only need to define a model to obtain structured data, without having to handle JSON parsing, error handling, or retries themselves.
Main capabilities include:
- A unified interface adapts to major LLM providers, allowing different models to be switched with the same code.
- Automatic retries: when validation fails, it automatically resends the request with the error information.
- Streaming support: partially generated objects can be obtained in a stream.
- Supports extracting complex, nested data structures.
- Pydantic-based validation, type safety, and IDE support.
How to use: after installing via a package manager, define a Pydantic model and call the Instructor interface to extract structured data from text. The documentation provides comprehensive guides, copyable example recipes, and blog tutorials.
Use cases: suitable for schema-first workflows that require fast, low-cost structured data extraction. If an application needs richer agent execution, built-in observability, or shareable traces, consider PydanticAI (the official agent runtime from the Pydantic team), which uses the same Pydantic models and adds features such as typed tools, replayable datasets, evaluations, and production dashboards.
Compared with alternatives: compared with raw JSON schemas, Instructor provides automatic validation, retries, streaming, and nested object support, without the need to manually write schemas; compared with LangChain/LlamaIndex, Instructor is lighter, faster, and easier to debug, focusing on doing one thing: structured extraction.
Adoption: more than 3 million downloads per month, more than 10K GitHub stars, and more than 1,000 community contributors. Companies and teams using Instructor include OpenAI, Google, Microsoft, AWS, and many YC startups.
Multilingual support: in addition to the original Python version, it also provides full TypeScript support as well as Ruby, Go, Elixir, and Rust implementations.
The project uses the MIT license. Information about specific fees, pricing, and similar details is not currently provided.