Instructor

Python library that steers LLMs into validated, structured outputs using type hints.

What is Instructor?

TL;DR: Python library that steers LLMs into validated, structured outputs using type hints.

Instructor is an open-source Python library that makes large language models return structured, validated data. You define a Pydantic model, and it handles the prompting, parsing, and retries needed to get objects that match that schema. It is a favorite among developers who want LLM calls to look like ordinary typed functions instead of fragile string parsing.

Best for: Python developers who need reliable structured output from LLM APIs.

Instructor key features

  • Pydantic-based schemas for structured LLM responses
  • Automatic retries and validation when the model misses the schema
  • Works with popular model providers and OpenAI-compatible APIs
  • Keeps LLM calls looking like typed Python functions

Use cases

  • Extracting invoices, tickets, or form fields into a schema
  • Forcing an agent tool call to return a valid JSON object
  • Replacing fragile regex or manual JSON parsing around LLM output

👍 Pros

  • Very practical and widely adopted in Python LLM apps
  • Validation and retries reduce broken downstream code
  • Simple mental model if you already use Pydantic

👎 Cons

  • It is a library, not a full agent framework
  • Schema design and edge cases are still your responsibility

Instructor FAQ

What is Instructor?
Instructor is an open-source Python library that makes large language models return structured, validated data. You define a Pydantic model, and it handles the prompting, parsing, and retries needed to get objects that match that schema. It is a favorite among developers who want LLM calls to look like ordinary typed functions instead of fragile string parsing.
Is Instructor free?
Instructor uses a Open source pricing model (verified Nov 28, 2026).
Does Instructor have an API?
Yes. Instructor offers an API for developers.
Does Instructor support Chinese, and is it available in China?
Instructor does not support Chinese, and it has unverified availability in mainland China.
What are the best alternatives to Instructor?
Popular alternatives to Instructor include OpenCode, Poolside, Qwen Code, LangChain4j.

Reviews

No reviews yet. Be the first to share your experience.

Alternatives to Instructor