# Outlines

> A Python library that guarantees LLM output matches a JSON schema, Pydantic model, regex or grammar

Source: https://talira.ai/catalog/outlines-zpje8mnw
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [ai / llm / structured output](https://talira.ai/categories/ai/llm/structured-output)
- Licence: Apache-2.0[^1]
- Pricing: Free and open source[^1]
- Pricing notes: Free and open source under Apache-2.0.
- Free tier: yes[^1]
- Backed by: [.txt](https://talira.ai/orgs/dottxt.md)

Outlines makes a language model's output follow the structure you ask for while it generates, instead of parsing and retrying afterwards. You pass an output type (a Literal of choices, an int, a Pydantic model, a JSON schema, a regular expression or a context-free grammar) and get output that's guaranteed to match it. The same code runs against local models through Hugging Face transformers and [llama.cpp](https://talira.ai/catalog/llama-cpp-g0rydd64.md), servers like [vLLM](https://talira.ai/catalog/vllm-f1czevpj.md) and [Ollama](https://talira.ai/catalog/ollama-gr2tx5nn.md), and APIs including OpenAI and Gemini. It also has prompt templates and applications that bundle a template with an output type. It's made by .txt, which also runs a hosted structured generation API in early access.

## Links

- Website: https://dottxt-ai.github.io/outlines/
- GitHub: https://github.com/dottxt-ai/outlines
- Docs: https://dottxt-ai.github.io/outlines/

## Problems it solves

- my LLM keeps returning broken JSON that fails to parse
- force a local model to answer with one of a fixed set of labels
- make an open-weights model's output always match my Pydantic model

## Features

- Constrains generation to a JSON schema or Pydantic model
- Regular expression constrained output
- Context-free grammar constrained output
- Multiple choice outputs
- Infers structure from function signatures
- Works with transformers, llama.cpp, vLLM, Ollama, OpenAI and Gemini
- Prompt templates

## Trust

Overall: 0.59 out of 1.
Signals: maintenance 0.61, adoption 0.84, momentum 0.77, community 0.91, backing 0.30, extensibility 0.00.

- last commit 4 days ago
- 1 commits in the last 90 days
- latest release 1.3.3 3 months ago
- 16.0k GitHub stars
- 189 contributors
- backed by .txt

## Alternatives

- [Instructor](https://talira.ai/catalog/instructor-nxkr8x7t.md): Structured outputs from LLMs, validated with Pydantic
- [Guidance](https://talira.ai/catalog/guidance-sjpze2ze.md): A guidance language for controlling large language models
- [LangExtract](https://talira.ai/catalog/langextract-zagt5t0y.md): Extract structured information from unstructured text using LLMs, with precise source grounding
- [BAML](https://talira.ai/catalog/baml-brpjagr9.md): A programming language for AI agents, with types that persist at runtime and built-in tests

## Sources

[^1]: https://github.com/dottxt-ai/outlines/blob/main/LICENSE (checked 25 Nov 2026)
