structured outputs for llms
13.5k
Stars
1.1k
Forks
52
Open issues
30
Contributors
AI Analysis
Instructor is a Python library that simplifies extracting structured data from LLMs by using Pydantic models for validation and schema definition. It works across multiple LLM providers (OpenAI, Anthropic, etc.) and handles JSON parsing, validation, and retry logic automatically. Best suited for developers building LLM applications that need reliable structured outputs—not a general-purpose tool but a specialized solution for LLM integration workflows.
Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.
AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.
Instructor brings Pydantic-validated structured outputs to any LLM provider with a single unified API
Instructor wraps LLM provider clients to return validated, typed Python objects instead of raw JSON strings. It handles schema generation, validation errors, automatic retries with error feedback to the model, and streaming partial objects — all via a Pydantic-first interface. Built for Python developers integrating LLMs into production applications, it abstracts provider differences (OpenAI, Anthropic, Google, Ollama, Groq, and more) behind one consistent call pattern. With 3M+ claimed monthly downloads and 13K+ stars, it has genuine adoption among the AI engineering community building extraction pipelines, structured RAG, and data transformation workflows.
Created in June 2023 by Jason Liu (jxnlco) at the onset of widespread LLM adoption. Originally tightly coupled to OpenAI's function-calling API, it evolved to support multi-provider structured outputs as the ecosystem matured and as native JSON modes proliferated.
Growth was driven by a clear, painful problem: LLM outputs are unreliable strings, but applications need structured data. Instructor arrived early, built a strong community through its author's active Twitter/X presence and documentation, and benefited from the broader explosion of LLM-powered application development in 2023-2025. Stars have plateaued relative to early growth as the structured-output space became more crowded with native provider features.
README claims 3M+ monthly downloads on PyPI, 100,000+ developers, and usage at teams from OpenAI, Google, Microsoft, AWS, and YC startups. These figures are self-reported and not independently verified here, but PyPI download badge is linked and the scale of the Discord community and fork count provide partial corroboration. The 1,000+ claimed contributors and 13K stars across 3 years of sustained activity are consistent with genuine production adoption at meaningful scale.
Appears to use a thin wrapper/proxy pattern around existing provider SDK clients, intercepting the completions call to inject Pydantic schema as the response format and post-process the response into validated model instances. Likely uses Pydantic's JSON schema generation and model_validate internally. The from_provider() unified entry point suggests an adapter layer per provider. Streaming support via Partial[T] likely uses incremental JSON parsing.
Not documented in README
Last push was June 23, 2026 — four days before evaluation date — indicating active, ongoing maintenance. With 1,091 forks and a Discord community, the project shows healthy contributor engagement. The README references current providers and models (gpt-4o-mini, claude-3-5-sonnet, gemini-pro), suggesting documentation is kept current. No signs of stagnation.
ADOPT IF: you are building Python applications that extract structured data from LLMs across multiple providers and want Pydantic validation, retries, and streaming without writing boilerplate. AVOID IF: you need guaranteed schema compliance without retry overhead (prefer constrained decoding tools like Outlines), or you are working in non-Python environments. MONITOR IF: your primary provider (e.g., OpenAI) expands native structured output support enough to eliminate the need for a wrapper layer, which could erode Instructor's value proposition over time.
Independent dimensions
Mainstream potential
7/10
Technical importance
7/10
Adoption evidence
7/10
- Provider-side native structured output improvements (OpenAI's response_format, Anthropic's tool_use schemas) may reduce the need for a wrapper library, shrinking Instructor's addressable problem.
- Retry-based validation is probabilistic — complex schemas or weak models may exhaust retries without convergence, which is a fundamental limitation of the approach versus constrained decoding.
- The project's public identity has been closely tied to its original author (jxnlco); a change in maintainership could affect momentum, though the 567-labs org transfer suggests some institutionalization.
- Self-reported adoption metrics (3M downloads, 100K developers) cannot be independently verified from available metadata; actual production penetration may differ from claimed figures.
- As the LLM ecosystem consolidates around a few dominant SDK patterns, a thin wrapper library must continuously track API changes across all supported providers, creating ongoing maintenance burden.
Instructor is likely to remain a widely-used utility library in the Python LLM ecosystem for the next 2-3 years, gradually ceding ground on simple single-provider use cases to native features while retaining value for multi-provider and complex validation workflows.
Newsletter
Get analyses like this every Monday
Free weekly digest of the most interesting open-source discoveries.
Languages
Information
- Language
- Python
- License
- MIT
- Last updated
- 4d ago
- Created
- 37mo ago
- Analyzed with
- anthropic/claude-haiku-4-5
Stars over time
Contributors over time
Top 100 contributors only — repos with more will plateau at 100.
Open issues
Thread-unsafe lazy loading in ModeRegistry.get_handlers() causes RegistryError under concurrency
`client.create()` mutates the caller's `messages` list (and sometimes message dicts) in place — affects far more than OpenAI TOOLS/JSON_SCHEMA/RESPONSES_TOOLS
[Docs]: Incorrect documentation for google.genai with vertex
Top contributors
Similar repos
dottxt-ai/outlines
Outlines is a Python library that constrains LLM outputs to structured formats...
mlabonne/llm-course
A structured, free course for learning Large Language Models, divided into...
allenai/open-instruct
Open Instruct is AllenAI's post-training codebase for instruction-tuning and...
| Repository | Stars | Week Δ | Language | Score | Updated |
|---|---|---|---|---|---|
|
|
13.5k | +105 | Python | 8/10 | 4d ago |
|
|
14.4k | — | Python | 8/10 | 20h ago |
|
|
1.4k | — | Python | 7/10 | 10h ago |
|
|
80.8k | — | — | 8/10 | 5mo ago |
|
|
3.8k | — | Python | 8/10 | 9h ago |
|
|
1.4k | — | Python | 7/10 | 4mo ago |
Outlines operates at the inference level, constraining token generation via finite-state machines to guarantee schema compliance without retries. Instructor works at the API call level, relying on model capability and retries. Outlines requires access to model weights (local/self-hosted); Instructor works with any API-based provider. Different deployment contexts, partially overlapping problem space.
The README itself recommends PydanticAI for agent workflows with observability and tooling. Instructor positions itself as the simpler, cheaper choice for schema-first extraction tasks. PydanticAI extends the same Pydantic foundation but adds agent runtime, typed tools, evals, and dashboards. The two are complementary rather than directly competitive.
llm is a CLI-first tool and Python library focused on prompt execution and model access. It doesn't offer Pydantic-validated structured output extraction as a core feature. Different primary audience: llm targets exploratory/scripting use cases; Instructor targets production extraction pipelines.
Major providers now offer native JSON mode and structured output features that overlap with Instructor's core value. Instructor's advantage is the unified multi-provider API, Pydantic integration, retry logic, and streaming partials — features not consistently available across providers natively.
rllm appears focused on RL-based LLM training and fine-tuning workflows rather than inference-time structured output extraction. Overlap is minimal; they address different points in the LLM development lifecycle.