Instructor
567-labs / instructor
Constrain LLM output with Pydantic models: automatic retries, streaming partial objects, function calling / JSON schema and multi-provider adapters make “return a struct” reliable.
Why choose it
- Schema, validation and retries live in one place, cutting parser code.
- Streaming partial objects suit long forms and live UI.
- Multi-provider support means changing models does not require rewriting the schema layer.
Not for
Not an agent framework; multi-step tool orchestration still needs LangGraph and similar.
Fallback is needed when a model lacks structured output, and retries cost tokens.
No prompt versioning or evaluation.
Minimum setup
- pip install instructor and define a small Pydantic schema.
- Ask the model for that object, then feed a bad example to see retries.
- Add streaming and a second provider; record failure rate and token cost.
Dependencies and cost
Python; an API key for at least one provider or a local OpenAI-compatible endpoint; production needs retry budgets and logs.
License and usage boundaries
MIT; connected model providers and SDKs have their own terms.
Open source is not automatically commercial-use friendly: GPL / AGPL are copyleft; code, model and output licenses are separate. Read the LICENSE and model card before launch, and involve legal when needed.
Alternatives and neighbors
- Pydantic AI — Lightweight,Write agents with Pydantic’s type system: inputs, outputs and tool arguments are strongly validated.
- DSPy — Production,Write prompts, retrieval and tool calls as composable modules, then optimise prompts and examples against a metric instead of hand-tuning chains.
- Outlines — Production,Structured generation: constrain token sampling with regex, JSON schema or a CFG so output is parseable; supports Transformers, vLLM, llama.cpp and other backends.
Next steps
- Open GitHub and read the README, LICENSE, latest release and issues first.
- Make an onboarding checklist for deployment dependencies, VRAM, data, network and permissions.
- Run a small sample first, then decide on production; never start with production data.