Skip to content

LLMs are powerful but their outputs are unpredictable. Most solutions attempt to fix bad outputs after generation using parsing, regex, or fragile code that breaks easily.

Outlines guarantees structured outputs during generation — directly from any LLM.

  • Works with any model - Same code runs across OpenAI, Ollama, vLLM, and more
  • Simple integration - Just pass your desired output type: model(prompt, output_type)
  • Guaranteed valid structure - No more parsing headaches or broken JSON
  • Provider independence - Switch models without changing code
  • Rich structure definition - Use Json Schema, regular expressions or context-free grammars

Get Started View Examples API Reference GitHub

See it in action

from pydantic import BaseModel
from typing import Literal
import outlines
import openai

class Customer(BaseModel):
    name: str
    urgency: Literal["high", "medium", "low"]
    issue: str

client = openai.OpenAI()
model = outlines.from_openai(client, "gpt-4o")

customer = model(
    "Alice needs help with login issues ASAP",
    Customer
)
# ✓ Always returns valid Customer object
# ✓ No parsing, no errors, no retries

Quick install

pip install outlines

Features

  • Reliable - Guaranteed schema compliance -- always valid JSON.
  • Feature-rich - Supports a large proportion of the JSON Schema spec, along with regex and context-free grammars.
  • Fast - Microseconds of overhead vs seconds of retries. Compilation happens once, not every request.
  • Simple - Outlines is a low-abstraction library. Write code the way you normally do with LLMs. No agent frameworks needed.

Supported inference APIs, libraries & servers

Who is using Outlines?

Hundreds of organisations and the main LLM serving frameworks (vLLM, TGI, LoRAX, xinference, SGLang) use Outlines. Prominent companies and organizations that use Outlines include:

Organizations are included either because they use Outlines as a dependency in a public repository, or because of direct communication between members of the Outlines team and employees at these organizations.

Still not convinced, read what people say about us. And make sure to take a look at what the community is building!

Outlines people

Outlines would not be what it is today without a community of dedicated developers:

About .txt

Outlines is built with ❤️ by .txt.

.txt solves the critical problem of reliable structured output generation for large language models. Our commercially-licensed libraries ensure 100% compliance with JSON Schema, regular expressions and context-free grammars while adding only microseconds of latency. Unlike open-source alternatives, we offer superior reliability, performance, and enterprise support.

Acknowledgements

Outlines was originally developed at @NormalComputing by @remilouf and @BrandonTWillard. It is now maintained by .txt.