Outlines
Published
At a glance
- What it is
- Outlines is an open-source Python library for structured generation with LLMs.
- Price from
- Open source Details
- Best for
- Python developers running open models locally or on vLLM; Pipelines that need output matching a strict schema or regex
- Official site
- dottxt-ai.github.io
- Last checked
- November 2026
- Watch out for
- It is a Python library, so other language stacks need a service wrapper such as the documented FastAPI setup.
Outlines is an open-source Python library for structured generation with LLMs. It is developed and maintained by .txt (dottxt), a company that also publishes research on structured generation and sells commercial versions of the technology. The library is licensed under Apache-2.0 and installs with pip install outlines.
The idea is to constrain the model while it generates, rather than parsing and repairing text afterward. You pass the output type you want along with the prompt. That type can be a basic Python type, a list of choices, a Pydantic model or JSON Schema, a regular expression, or a context-free grammar. Function signatures can also be used to infer a structure. The library keeps its abstractions thin and does not require an agent framework. Extras in the docs include a regex DSL, prompt templates, logits processors, chat templating, vision-language model support and a FastAPI deployment guide.
Outlines works with local and served models through Transformers, llama.cpp, MLX-LM, vLLM, SGLang, TGI and Ollama. It also lists hosted APIs from OpenAI, Anthropic, Gemini and Dottxt. Under the hood it can use outlines_core, llguidance or xgrammar as its constraint backend. Constrained decoding is most direct with local models where the library controls token sampling; with hosted APIs it depends on what each provider exposes, and the docs' feature matrix shows no JSON Schema, regex or grammar support for Anthropic.
Key features
- Constrained generation
- Output is shaped during decoding so it matches the requested type, instead of being fixed up after the fact.
- JSON Schema and Pydantic
- Pydantic models and JSON Schemas can define the output, with support for a large part of the JSON Schema spec.
- Regex and grammars
- Regular expressions and context-free grammars can constrain free-form formats beyond JSON.
- Multiple choice and function calls
- You can restrict output to fixed options or infer a structure from a Python function signature.
- Wide backend support
- It runs with Transformers, llama.cpp, MLX-LM, vLLM, SGLang, TGI and Ollama, plus OpenAI, Anthropic, Gemini and Dottxt APIs.
- Pluggable constraint engines
- The API reference lists outlines_core, llguidance and xgrammar as backends.
- Templates and tooling
- Prompt templates, a regex DSL, logits processors and chat templating come with the library.
Pricing
As of November 2026, Outlines is free and open source under the Apache-2.0 license, installed with pip. You pay for whatever model you run it with, either your own hardware or a hosted API. The maker, .txt, sells commercial products separately (.json, .lambda, an early-access API and pilots for inference providers), but its site lists no public prices and asks teams to start a pilot through a form.
Best for
- Python developers running open models locally or on vLLM
- Pipelines that need output matching a strict schema or regex
- Teams building inference services with structured output
- Researchers experimenting with constrained decoding
Limitations
- It is a Python library, so other language stacks need a service wrapper such as the documented FastAPI setup.
- The docs say it covers a large proportion of the JSON Schema spec, not all of it.
- How much structure you get with hosted APIs depends on each provider; for Anthropic the docs list no JSON Schema, regex or grammar support.
- .txt's commercial products have no public pricing and require a pilot or access request.
Verdict
Outlines is a solid choice for constrained decoding in Python, especially with open models you host yourself. It is narrow on purpose: it shapes output and leaves orchestration to you. Check JSON Schema coverage and provider support before relying on it with hosted APIs.
Sources
Written from the vendor's own site and documentation, checked November 2026. We have no paid relationship that affects what this page says.
- github.com /dottxt-ai/outlines
- dottxt-ai.github.io /outlines/latest
- dottxt.ai
- dottxt-ai.github.io /outlines/latest/features/models
How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.