Outlines is a Python library for making language models generate predictable, structured outputs. Instead of repairing malformed responses afterward, it constrains generation to match a requested type or format. Developers can require predefined choices, primitive Python types, Pydantic models, JSON schemas, regular expressions, function signatures, or custom grammars. The same interface works with local models, inference servers, and hosted APIs from several providers. Supported integrations include Transformers, llama.cpp, vLLM, Ollama, OpenAI, and Gemini. It also provides reusable prompt templates and application abstractions for packaging prompts with output constraints. Outlines is designed for extraction, classification, tool calling, automation, and other production workflows that require valid machine-readable results.
Features
- Constrained structured generation
- JSON Schema and Pydantic outputs
- Regular expression and grammar constraints
- Typed function-call parameter generation
- Local and hosted model integrations
- Reusable Jinja-based prompt templates