Skip to content
aicoolies logo
Guidance logo

Guidance

Constrained generation that guarantees valid LLM outputs every time

Guidance is Microsoft's structured generation library that enforces output constraints directly within LLM decoding. It supports JSON schemas, regex patterns, grammars, and interleaved generation-and-control flow to guarantee valid outputs from any compatible model. Works with local models via llama.cpp, Transformers, and remote APIs including OpenAI and Anthropic. Eliminates retry loops and post-processing for structured data extraction.

About Guidance

Guidance is a structured generation framework from Microsoft that constrains large language model outputs at the token level during decoding. Instead of relying on prompt engineering and hoping the model returns valid JSON, developers define schemas, regex patterns, or context-free grammars and Guidance guarantees the output conforms exactly. This approach eliminates parsing failures, retry loops, and the brittle post-processing code that typically surrounds LLM calls in production pipelines.

The library integrates directly with popular model runtimes including llama.cpp, HuggingFace Transformers, and vLLM for local inference, plus remote providers like OpenAI and Anthropic via their APIs. Its Python-native syntax lets developers interleave free-form generation with hard constraints in a single program — for example, generating a product description and then forcing the model to output a strictly-typed JSON object with price, category, and rating fields. Advanced features include stateful multi-turn control flow, subgrammar composition, and token healing for cleaner outputs.

Guidance is fully open-source under the MIT license with 19,000+ GitHub stars and strong adoption in enterprise AI pipelines. It is particularly valuable for agent tool-calling, function routing, and any workflow where downstream code depends on predictable LLM output structure. The library integrates well with LangChain, LlamaIndex, and custom orchestration layers, making it a foundational building block for reliable AI applications.

Pricing & Platform Specs

Pricing Summary

Guidance is a free, open-source library for constrained decoding and structured LLM generation. It has no software license fees or hosted SaaS subscriptions; users only pay for any downstream model API tokens used.

Supported Platforms

Python library — works on any OS with Python 3.9+

Explore categories, tags & use cases

Community experience

Sources & verification

Sources checked
Content verified

Verification dates are editorial checks. Routine CMS saves and automatic updatedAt timestamps do not advance them.

FAQ

What is Guidance?

Guidance is Microsoft's structured generation library that enforces output constraints directly within LLM decoding. It supports JSON schemas, regex patterns, grammars, and interleaved generation-and-control flow to guarantee valid outputs from any compatible model. Works with local models via llama.cpp, Transformers, and remote APIs including OpenAI and Anthropic. Eliminates retry loops and post-processing for structured data extraction.

Is Guidance free?

Yes — Guidance is open source and free to use. Guidance is a free, open-source library for constrained decoding and structured LLM generation. It has no software license fees or hosted SaaS subscriptions; users only pay for any downstream model API tokens used.

Is Guidance open source?

Yes — Guidance is open source.

Is Guidance still maintained?

Yes — Guidance is active. Its listing was last verified on August 26, 2026.