Debuly
Outlines logo

Outlines

Python library from .txt that makes LLM output match a type you define, such as a Pydantic model, enum or regex, during generation.

Open source

What is Outlines?

Outlines is an open-source Python library for structured generation. Instead of parsing and repairing model replies afterwards, you pass an output type along with the prompt, for example Literal for a fixed choice, int for a number or a Pydantic model for a complex object, and Outlines guarantees the generated text fits that structure. The same call pattern, model(prompt, output_type), runs against Transformers models and server back ends such as vLLM and Ollama, and the README says it works across OpenAI, Ollama and vLLM, which lets you switch providers without rewriting code. Examples include support ticket triage, product categorization, event parsing with union types, document classification, function calling for meeting scheduling and reusable prompt templates. It is built by the .txt team, and the README says NVIDIA, Cohere, Hugging Face and vLLM use it. The library is free to install from PyPI with pip install outlines, while a separate .txt API is in early access.

Use cases

  • Force LLM output into valid JSON
  • Extract structured data from free text
  • Classify text into fixed labels
  • Triage support emails into tickets
  • Categorize products from descriptions
  • Build function-calling arguments
  • Template prompts for repeated tasks

Who it's for

  • Python developers
  • ML engineers
  • AI application builders
  • Teams running open models

Why use Outlines

  • Removes broken-JSON failures, because structure is enforced while the model generates instead of fixed after.
  • Keeps code portable: swapping models or providers does not change how you ask for typed output.
  • Fits normal Python habits, since you describe results with Pydantic models, enums and Literal types.
  • Costs nothing to adopt, as it is an open-source package installed with pip.
  • Handles small local models well enough for tasks like classification and extraction.

Outlines features

  • Output types from Literal, int and enums to Pydantic models
  • Guaranteed valid structure during generation
  • Same call pattern for any supported model
  • Hugging Face Transformers model support
  • vLLM and Ollama server support
  • Union types for answers with a fallback
  • Batch generation over lists of prompts
  • Reusable prompt templates from strings or files
  • Function-calling style argument generation
  • Installable from PyPI

Outlines integrations

  • Hugging Face Transformers
  • vLLM
  • Ollama
  • OpenAI
  • Pydantic

How to get started with Outlines

  1. Install the package with pip install outlines.
  2. Wrap your model, for example with outlines.from_transformers, or connect to a vLLM or Ollama server.
  3. Define the output type you want, such as a Literal, an int or a Pydantic class.
  4. Call model(prompt, output_type) and Outlines constrains generation to that structure.
  5. Validate the result with Pydantic's model_validate_json and pass the typed data to the rest of your program.

Outlines limitations

  • A library for developers, not an end-user application
  • The .txt hosted API is in early access and requires a request
  • Most control comes when you run the model yourself

Outlines pricing

Outlines is open source, so you can use and self-host it for free.

Prices can change and may vary by country or exclude tax. Check the official pricing page.

Outlines alternatives

The main Outlines alternatives listed on Debuly are Instructor, Guidance, BAML, LMQL, TypeChat and Marvin. The table compares pricing and platforms; order is A–Z.

Outlines compared with its alternatives
ToolPricingStarting pricePlatforms
OutlinesOpen source—API
BAMLOpen source—CLI, macOS, Linux, Windows
GuidanceOpen source—API
InstructorOpen source—API, Self-hosted
LMQLOpen source—Python, CLI, Web, Self-hosted
MarvinOpen source—Python, CLI
TypeChatOpen source——
  1. BAML

    Open-source, TypeScript-like programming language for agents, with typed LLM functions, built-in tests and SDK generation.

  2. Guidance

    Python library for steering language models, combining constrained generation with ordinary control flow so outputs follow regexes, grammars or JSON schemas.

  3. Instructor

    Open-source library that gets validated, typed structured data out of LLMs using Pydantic models and automatic retries.

  4. LMQL

    Programming language from ETH Zurich for LLM prompting that adds Python control flow, typed variables and hard output constraints.

  5. Marvin

    Open source Python framework from Prefect for getting structured output from LLMs and building agent workflows from tasks and threads.

  6. TypeChat

    Microsoft library that builds natural-language interfaces by using your own types to define what a model must return.

Outlines FAQ

How much does Outlines cost?

The library is free to install from PyPI. The separate .txt API is in early access, and the README gives no price, only a request-access form.

Is there a free plan for Outlines?

There are no plans. Outlines itself is a free open-source package; you pay only for the compute or API of whichever model you run.

Which models does Outlines work with?

The README says the same code runs across OpenAI, Ollama and vLLM, and the examples use Hugging Face Transformers models such as Phi-3-mini.

Does Outlines have an API?

Outlines is a Python API for your own code. .txt also offers a hosted .txt API, which is currently in early access and available by request.

Is Outlines open source?

Yes. The repository is open source under the Apache-2.0 licence and the package is published on PyPI.

What are alternatives to Outlines?

Related tools for structured LLM output include Instructor, Guidance, BAML, LMQL and TypeChat.

Sources & verification

Facts on this page come from the official sources below, each with the date we read it. Written by Debuly; the vendor did not review this page.

SourceTypeAccessed
github.com/dottxt-ai/outlinesofficial

Image credits

  • Logo: from avatars.githubusercontent.com · fetched · Vendor trademark, used only to identify the product; removed on request
  • Cover: none collected yet, so a generated tile is shown.

Spot an error? Report an issue with this listing. We also remove a logo or image on the owner's request.