ScriptsMay 11, 2026·2 min read

Instructor — Typed Structured Outputs for LLMs

Instructor turns LLM replies into validated Pydantic models with retries. `pip install instructor`, then extract typed objects across major providers.

Agent ready

This asset can be read and installed directly by agents

TokRepo exposes a universal CLI command, install contract, metadata JSON, adapter-aware plan, and raw content links so agents can judge fit, risk, and next actions.

Stage only · 29/100Stage only
Agent surface
Any MCP/CLI agent
Kind
Script
Install
Single
Trust
Trust: Established
Entrypoint
README.md
Universal CLI install command
npx tokrepo install e4780821-245b-49db-9315-ba6260689aa5
Intro

Instructor turns LLM replies into validated Pydantic models with retries. pip install instructor, then extract typed objects across major providers.

  • Best for: backend teams who need reliable, typed extraction (JSON-safe) without hand-written parsers and fragile regex cleanup
  • Works with: Python, Pydantic models, OpenAI/Anthropic/Google/Ollama providers (per repo examples)
  • Setup time: 8 minutes

Quantitative Notes

  • GitHub stars (verified): see Source & Thanks
  • Setup time ~8 minutes
  • Install command: pip install instructor (repo)

Practical Notes

Use Instructor when you already know the shape of the answer and you want the model to fill it in with high reliability. Start with one Pydantic model per call (e.g., User, ProductReview), add tight field constraints (enums, ranges), then layer in retry budgets. Once stable, treat the schema as an API contract: version it, add regression examples, and monitor validation failures as a quality metric.

Safety note: Schema discipline matters: oversized models and ambiguous fields cause retries, latency, and cost spikes.

FAQ

Q: What problem does Instructor solve? A: It enforces a typed schema on LLM outputs (Pydantic) and retries invalid generations, so you ship structured results instead of brittle parsing.

Q: Is it only for OpenAI? A: No. The repo shows provider strings for OpenAI, Anthropic, Google, and local Ollama; the API stays consistent.

Q: How do I reduce failures? A: Keep the schema minimal, constrain enums, and ask for one object per call; smaller schemas validate more reliably and retry less.


🙏

Source & Thanks

GitHub: https://github.com/567-labs/instructor Owner avatar: https://avatars.githubusercontent.com/u/152629781?v=4 License (SPDX): MIT GitHub stars (verified via api.github.com/repos/instructor-ai/instructor): 12,947

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets