← all repositories
567-labs/instructor

Because LLMs speak English, not JSON Schema

It wraps major LLM clients so you can request structured output with a Pydantic model instead of brittle JSON schemas.

13.6k stars Python LLMOps · Eval
instructor
Velocity · 7d
+9.3
★ / day
Trend
cooling
star history

What it does

Instructor wraps major LLM clients—OpenAI, Anthropic, Google, Ollama, Groq, and others—so that a chat.completions.create call can accept a Pydantic BaseModel as its response_model. The library handles the underlying function-calling or JSON-mode plumbing, validates the returned payload against your model, and retries automatically if validation fails. You get back a native Python object with IDE autocomplete and type checking rather than a raw dict you parse yourself.

The interesting bit

The abstraction is aggressively thin: it does not replace the client, it just wraps it. You keep using the same chat.completions.create API you already know, but now it returns strictly typed objects. The README itself notes that if you need agents, observability, or shareable traces, you should use PydanticAI instead—Instructor is deliberately scoped to extraction and schema enforcement.

Key highlights

  • Supports OpenAI, Anthropic, Google, Ollama, Groq, and others through a unified from_provider interface.
  • Automatic retries with validation-error feedback when the LLM returns bad field values.
  • Streams partial Pydantic objects as tokens arrive via Partial[Model].
  • Handles nested models and lists without manual JSON Schema drafting.
  • Ports exist for TypeScript, Ruby, Go, Elixir, and Rust, though Python is the reference implementation.

Verdict

If you are building pipelines that turn unstructured text into structured records—entity extraction, classification, form filling—Instructor is a focused, low-ceremony choice. If you are building autonomous agents or need heavy observability, the authors themselves suggest looking at PydanticAI instead.

Frequently asked

What is 567-labs/instructor?
It wraps major LLM clients so you can request structured output with a Pydantic model instead of brittle JSON schemas.
Is instructor open source?
Yes — 567-labs/instructor is open source, released under the MIT license.
What language is instructor written in?
567-labs/instructor is primarily written in Python.
How popular is instructor?
567-labs/instructor has 13.6k stars on GitHub and is currently cooling off.
Where can I find instructor?
567-labs/instructor is on GitHub at https://github.com/567-labs/instructor.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.