instructor

By 567 Labs

Structured, validated outputs from any LLM — define a Pydantic model and get a typed object back.

v1.15.42026-06-28PythonMIT
13.6k Completely free Open source

Doc version 1.0 · Updated

Related tools

Overview

instructor turns an LLM into a typed function: you describe the output with a Pydantic model and get a validated Python object back instead of free-form text.
It wraps the call — routing through LiteLLM — and reprompts until the response fits your schema, so downstream code can rely on the types.

flowchart LR
  schema[Pydantic model] --> inst[instructor]
  msg[messages] --> inst
  inst --> llm[LLM via LiteLLM]
  llm --> obj[typed object]

The Code samples tab shows a basic extraction and a validated-with-retry example — pick from the selector to compare.

When to use it

Reach for instructor whenever an LLM’s output feeds code that expects structure — extraction, classification, routing — and you want validation and retries instead of brittle JSON parsing.