# Guidance

> A guidance language for controlling large language models

Source: https://talira.ai/catalog/guidance-sjpze2ze
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), [languages / python](https://talira.ai/categories/languages/python)
- Licence: MIT[^1]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Backed by: [Guidance AI](https://talira.ai/orgs/guidance-ai.md)

Guidance is a Python library for steering language models: you build a prompt with ordinary Python (role blocks, `gen()`, `select()`, conditionals, loops and tool calls) and constrain what the model may generate at each step with regular expressions, context-free grammars or a JSON schema (including Pydantic models), so the output always parses. Because the structure is enforced during decoding, tokens the grammar fixes can be fast-forwarded, which its makers say cuts latency and cost compared with conventional prompting or fine-tuning. Reusable pieces are written as `@guidance` functions, and it runs against several backends, including Hugging Face Transformers, llama.cpp and OpenAI, with full grammar support only where the backend allows it. In a Jupyter notebook it shows a widget of the generation.

## Links

- GitHub: https://github.com/guidance-ai/guidance

## Problems it solves

- force a local LLM to return valid JSON that matches my Pydantic model every time
- make the model answer with one of a fixed set of options instead of free text
- constrain LLM output to a regex like a number or a date
- mix my own Python control flow and tool calls with generation in one prompt
- cut tokens and latency when the output format is mostly fixed
- write reusable prompt components as Python functions
- structured generation with llama.cpp or Hugging Face Transformers models

## Features

- gen() with regex and grammar constraints
- select() from a fixed set of options
- JSON generation from a JSON schema or Pydantic model
- context-free grammars for output
- interleaved control flow, loops and tool use
- @guidance decorator for reusable components
- token fast-forwarding where the structure is fixed
- backends: Transformers, llama.cpp, OpenAI and others
- Jupyter notebook widget

## Trust

Overall: 0.47 out of 1.
Signals: maintenance 0.27, adoption 0.87, momentum 0.80, community 0.77, backing 0.30, extensibility 0.00.

- latest release 0.3.2 8 months ago
- 21.8k GitHub stars
- 84 contributors
- backed by Guidance AI

Warnings:

- last commit 6 months ago

## Alternatives

- [Instructor](https://talira.ai/catalog/instructor-nxkr8x7t.md): Structured outputs from LLMs, validated with Pydantic
- [Outlines](https://talira.ai/catalog/outlines-zpje8mnw.md): A Python library that guarantees LLM output matches a JSON schema, Pydantic model, regex or grammar

## Sources

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