Outlines is the structured generation library from the .txt team that makes large language models produce output guaranteed to follow your format. It has more than 15,900 stars on GitHub and is trusted in production by teams at NVIDIA, Cohere, Hugging Face and vLLM.
Prompting alone cannot promise valid JSON. Outlines instead constrains the sampling process itself with regular expressions, JSON schemas or context-free grammars, so generated text always parses and always matches the shape your code expects. It plugs into popular local inference engines and hosted model APIs, integrates with Pydantic for type-safe schemas, and uses finite-state-machine guided generation to keep overhead low. For agents, extraction pipelines and tool calling, that guarantee removes a whole class of retry-and-repair hacks.
The guarantee Outlines provides is stronger than the “JSON mode” offered by most APIs, which only promises a best effort. By masking the model’s vocabulary at every generation step, invalid continuations become literally unreachable, so a schema violation cannot occur no matter how the prompt is phrased. Precomputed finite-state machines are cached and reused, keeping the constraint overhead small compared with the cost of generation itself. In practice this turns flaky prompt engineering into an ordinary software contract: define a Pydantic model, and the LLM’s answer arrives as an object your code can trust.
The Outlines library is free and open source under the Apache-2.0 license. The .txt team also offers a commercial hosted API, currently in early access, plus enterprise schema services for teams that want a managed option.
LLM application developers, data-extraction pipelines, and agent builders who need tool calls and structured outputs that never fail to parse.