# Outlines

A Python library that guarantees structured output from a language model during generation itself, by specifying a desired output type such as a Python literal, an integer or a Pydantic model, rather than parsing or fixing the output afterward.

Outlines guarantees structured outputs from a large language model during generation, rather than trying to fix unpredictable output afterward with parsing, regular expressions or other fragile code.

Its API mirrors Python's own type system: a call passes the desired output type directly, from a Literal for a yes or no answer, to an int for a numeric value, to a Pydantic model for a complex object, and Outlines ensures the generated data matches that structure exactly. The same code runs across different model backends, including OpenAI, Ollama and vLLM, so switching providers does not require changing the calling code.

It installs from PyPI and is written in Python, released under the Apache 2.0 license.

Website: https://dottxt-ai.github.io/outlines/
