Guidance
Library for constrained, structured generation from language models
Guidance is profiled here as a Prompt Engineering tool for engineering teams. Read about features, pricing, and how it compares to related options in the tools directory.
Description
Guidance is an open-source Python library from Microsoft that gives developers fine-grained control over how a language model generates text. Programs written with Guidance interleave plain prompting with control structures and generation constraints, so the model fills specific slots while the code dictates structure. By constraining output to grammars, regular expressions, or fixed formats, Guidance produces valid JSON, code, or templated text on the first pass and reduces wasted tokens on retries. Because constraints are enforced during decoding, the model cannot drift outside the requested format even on long generations.
Key Capabilities:
Constrained decoding that forces output to match a grammar or regular expression
Interleaved control flow that mixes Python logic with model generation
Guaranteed structure for JSON, code, and templated formats
Token healing that avoids broken tokens at constraint boundaries
Support for local models and hosted provider APIs
Reusable functions that package prompt patterns into callable components
Alternative tools
- Outlines
Structured text generation with schema and regex constraints
- Not Diamond
Intelligent router that picks the best model per prompt
- CrewAI
Role-based framework for orchestrating multi-agent teams
- Dify
Open-source AI workflow platform with 131,000 GitHub stars and its own orchestration runtime.
- Flowise
Visual drag-and-drop builder for LLM workflows, agents, and RAG pipelines — now part of Workday.
- Langfuse
Open-source LLM engineering platform for tracing, evaluation, and prompt management.
