567-labs/instructor
structured outputs for llms
What it solves
Getting reliable, structured data out of Large Language Models (LLMs) is difficult because they naturally output unstructured text. Developers usually have to write complex JSON schemas, manually parse responses, handle validation errors, and build retry logic. This tool automates that entire process.
How it works
It uses Pydantic models to define exactly what data you want to extract. You pass this model to the library, which handles the communication with the LLM provider. If the LLM returns data that doesn't match your model, the library automatically retries the request with the error message until it gets a valid response. It works with all major LLM providers using a consistent interface.
Who it’s for
It is designed for developers building AI applications who need to reliably extract typed, validated data from LLMs without writing boilerplate code for parsing or error handling. It is ideal for those who want a simple, schema-first approach to data extraction.
Highlights
- Automatic validation and error handling using Pydantic.
- Built-in retry logic for failed extractions.
- Support for streaming partial objects as they are generated.
- Handles complex, nested data structures automatically.
- Unified interface that works across OpenAI, Anthropic, Google, Ollama, and other providers.
- Available in multiple programming languages including Python, TypeScript, Ruby, Go, Elixir, and Rust.
Related
- Project
- Project
- Project
- Dispatch
- Project