# Instructor

A Python library for getting reliable, typed structured output from any large language model, built on Pydantic for validation and automatic retries instead of hand-written JSON parsing.

Instructor gets structured, validated output from a large language model by defining a Pydantic model and asking for it back as that type, without writing a JSON schema, parsing the response by hand, or writing custom retry logic. The same client code works across every major LLM provider, selected through a single provider string.

When the model returns output that fails validation, Instructor automatically retries the request with the validation error included, so the model can correct itself. It also supports streaming partial objects as they are generated, so an application can display fields as they arrive, and it extracts nested, complex data structures such as a user record containing a list of addresses.

The maintainers describe Instructor as suited to fast, schema-first extraction, and recommend the related PydanticAI project, which shares the same Pydantic models, for applications that need richer agent runs with built-in observability and replayable evaluation datasets.

Website: https://python.useinstructor.com/
