Guidance
Open-source Python library that constrains LLM output with regex, context-free grammars, and inline control flow.
Read Guidance's source to learn constrained decoding — gen(regex=...), select(), and the Mock model explain the technique better than most write-ups, and the README's Phi-4-mini example is a runnable lesson. Adopt it for new production work only with eyes open: the repo was archived on October 22, 2023, so no fixes are coming and the 266 open issues and 88 pull requests will not be triaged. Existing Guidance code is fine to keep running; a fresh 2026 project means owning the dependency yourself or using a maintained constrained-generation library instead.
Verified 9h ago · liveness 81/100 · cite: rightaichoice.com/tools/guidance
- Developers who need guaranteed-valid JSON, SQL, or extracted fields from an LLM
- Researchers prototyping grammar-constrained decoding offline with the Mock model
- Teams keeping existing Guidance code alive on a pinned dependency
- Educators teaching how constrained decoding works under the hood
- New production projects that need ongoing maintenance and bug fixes
- Teams that must track the newest model backends
- High-stakes applications where unpatched issues are unacceptable
We scan live Reddit threads, YouTube comments, X posts, G2 reviews and other communities — and hand you an honest verdict in under a minute.
- Honest verdict, not marketing
- Real pros & cons from real users
- Attributed quotes with receipts
3 free scans · no card needed
Skip Guidance if you are starting a new production service in 2026 that needs upstream bug fixes or support for whatever model backend ships next quarter — the project has been archived since October 22, 2023.
Model objects are immutable, so every `lm += ...` builds a copy; on long multi-step grammars that copying cost shows up as memory and latency you did not budget for.
Guidance is MIT-licensed and free — $0 forever, no seat math to model. The real cost is engineering time: a solo developer or research group prototyping grammars spends nothing but a weekend, while a funded team putting it in production should budget for owning a fork. Compare against actively maintained constrained-generation libraries before committing headcount.
In short
Guidance — Open-source Python library that constrains LLM output with regex, context-free grammars, and inline control flow. Best for Developers who need guaranteed-valid JSON, SQL, or extracted fields from an LLM, Researchers prototyping grammar-constrained decoding offline with the Mock model, Teams keeping existing Guidance code alive on a pinned dependency. Free to use.
No head-to-head comparison for Guidance yet — the alternatives below are the closest matches we list.
What's new in Guidance
Checked todayAcross the latest 1 update: 1 news mention.
What people actually say about Guidance — is it worth it?
We ran a structured research pass across product reviews, community discussions, and post-purchase forum threads to surface the patterns vendors won't publish themselves. Below: the recurring strengths, the hidden costs people mention most, and the cohort that consistently regrets adopting this tool.
7 mentions across 5 sources (Hacker News, YouTube, Product Hunt, Stack Overflow, Lemmy), 87 more we could not attribute · researched Oct 15, 2026.
Weighted by the 94 posts each of 5 sources contributed.
- +Regular-expression and context-free-grammar constraints guarantee structurally valid LLM output
- +Pythonic control flow — loops, conditionals, tool calls — interleaves cleanly with generation
- +select() forces a model to pick from a fixed list, useful for classification and routing
- +Mock model validates grammars offline with zero API calls, saving tokens during development
- +grammar.match() lets you test candidate strings against a constraint before touching a model
- −Organization archived October 22, 2023 — no new features, backend updates, or fixes since
- −Frozen Transformers, llama.cpp, and OpenAI backends will eventually drift from upstream APIs
- −Sparse real-world developer discussion means limited community help for edge cases
- −Assumes comfort with regex and context-free grammars — not beginner-friendly
- −Archived status makes it a risky choice for production systems needing long-term support
- • No license fee, but you absorb maintenance risk — the repo is archived and unmaintained
- • Upstream SDK drift means you may have to fork and patch backends yourself
- • Learning curve costs developer hours for anyone new to grammars
- • There is no paid support tier or vendor to escalate to
Viability Score
How well maintained and how widely used is Guidance? Built from what the vendor actually publishes (docs, changelog, tutorials, integrations, pricing), whether the site is live, and how much real users discuss it. How we calculate this
Last calculated: October 2026
How we score →Key Features
- gen(regex=...) constrains output to match a regular expression
- gen(max_tokens=...) caps generation length
- select() forces the model to pick from a predefined list of choices
- Context-free grammar (CFG) constraints for structured output
- Pythonic control flow (loops, conditionals, tool use) interleaved with generation
- @guidance decorator builds reusable guidance functions
- system() / user() / assistant() blocks map generation to chat roles
- Capture generated text into named variables via gen(name=...)
- grammar.match() checks a candidate string against a constraint
- Mock model runs a full grammar offline with no model API calls
- Jupyter notebook widget renders the generation process interactively
- Immutable model objects keep state copies safe and debuggable
- Python interface to LLMs using ordinary Python idioms
- Backends documented: Transformers, llama.cpp, OpenAI
- Installable from PyPI with pip install guidance
About Guidance
Guidance is a Python library for steering language models instead of hoping prompt wording does the job. The core primitives are gen(regex=r"\d+") for regex-bound output and select(["A","B","C"]) for forcing a pick from a known list; context-free grammars extend the same idea to whole structured blocks. You write ordinary Python around the call, so loops, conditionals, and system()/user()/assistant() chat blocks sit inline with generation. The README example runs a Microsoft Phi-4-mini-instruct model through Transformers and captures output into a named variable with gen(name="lm_response", max_tokens=20). Generated text lands in names you reference later, the @guidance decorator packages a pattern into a reusable function, model objects are immutable so copies are cheap, and a Jupyter widget renders generation as it happens. Offline iteration is the part worth noting: grammar.match() checks a candidate string against your constraint before you spend tokens, and the Mock model runs the full grammar with no API calls at all. Install is pip install guidance from PyPI, with Transformers, llama.cpp, and OpenAI documented as backends. Going in, know that the guidance-ai organization was archived on October 22, 2023 — the code still installs and the grammar engine still works, but it is a frozen dependency.
Behind the Verdict
Guidance's real contribution is that it moves constraint out of the prompt and into the decoder. `gen("lm_age", regex=r"\d+", temperature=0.8)` cannot return a sentence where a number is required; `select()` cannot return an option that isn't in your list. Because the constraint is code, you can loop, branch, and call tools between generation steps — the README's claim that this cuts latency and cost versus conventional prompting or fine-tuning is the design thesis, and the inline control flow is what makes it plausible rather than marketing. The developer experience is unusually good for a research-adjacent library. Model objects are immutable, so `lm = phi_lm` gives you a cheap copy and debugging stays sane. `gen(name="lm_response", max_tokens=20)` puts output in a named variable instead of a string you have to parse back out. `grammar.match()` validates a candidate string before you pay for an API call, and the Mock model runs the whole grammar offline — you can develop and unit-test a constrained flow with no backend at all. The Jupyter widget renders generation as it streams, which is the fastest way to build intuition for what constrained decoding is doing. Where it falls down is maintenance, and that is not a small caveat. The guidance-ai organization was archived on October 22, 2023. The PyPI package still installs, but there are no upstream fixes, no new backend support, and the GitHub repo shows 266 open issues and 88 open pull requests frozen in place. Constrained generation often depends on logit-level access, which is exactly the layer that moves when Transformers, llama.cpp, or an OpenAI SDK ships a breaking change — and nobody is patching that here. So the fit is narrow and clear. It is an excellent teaching artifact, a fine way to keep an existing constrained-generation pipeline alive on a pinned dependency, and a reasonable prototyping tool for researchers who want to test a CFG design offline with the Mock model. It is a poor choice for a new production service that needs to track current model backends, and a bad one for anything where an unpatched bug is unacceptable. Budget for owning the fork if you build on it.
Researching Guidance? Get your full AI stack in 60 seconds.
Free, no signup — tell us your goal and get tools matched to your budget & existing stack.
Real-world workflow fit
Concrete scenarios for the personas Guidance actually fits — and what changes day-one when you adopt it.
You install with pip install guidance, load microsoft/Phi-4-mini-instruct through the Transformers backend, and run the README's chat example with system(), user(), and assistant() blocks.
Outcome: You see the exact rendered prompt-output string in your terminal, or the interactive widget in Jupyter, and understand in one sitting what constrained decoding buys you.
You draft a context-free grammar, validate candidate strings with grammar.match(), then run the whole flow against the Mock model with zero API calls.
Outcome: The grammar is proven correct offline, so the first real model call is spent on output quality rather than syntax debugging.
Your extraction service calls gen(regex=...) and select() on a pinned Transformers version, and you need a field guaranteed to be a digit string or a known label.
Outcome: The constraint still holds and output lands in named variables; you keep the pin in place and own any backend breakage internally.
Use Cases
- Constrain a local model to emit guaranteed-valid JSON using regex or grammar constraints
- Generate syntactically correct SQL from an open-source model
- Enforce a multi-role chat format in a local Llama model
- Force a fixed-choice answer (A/B/C/D) with select() instead of parsing free text
- Prototype and test grammars offline with the Mock model before spending API tokens
- Teach constrained decoding by reading a working implementation
Models Under the Hood
as of 2026-10-16
Limitations
- The guidance-ai organization was archived on October 22, 2023 and is no longer maintained, though the package remains installable from PyPI.
- The GitHub repo carries 266 open issues and 88 open pull requests that will not be triaged.
- Constrained generation guarantees may depend on logit-level access, and some backends may require specific library versions — a moving target nobody is patching.
- The template language has a learning curve, and it is not an agent or orchestration framework.
- Treat it as a frozen dependency: no upstream fixes, no new backend support.
as of 2026-10-22
Verification history
We have re-verified Guidance 22 times since . Each pass re-reads the vendor's own pages and re-checks every listed field against that evidence; passes where nothing had changed are marked as such.
- — re-verified summary, description, our verdict, our analysis, pricing model, pricing tiers, features, integrations, who it suits, who should skip it
- — re-verified summary, description, our verdict, our analysis, pricing model, pricing tiers, features, integrations, who it suits, who should skip it
- — re-verified summary, description, our verdict, our analysis, pricing model, pricing tiers, features, integrations, who it suits, who should skip it
- — re-verified summary, description, our verdict, our analysis, pricing model, pricing tiers, features, integrations, who it suits, who should skip it
- — re-verified summary, description, our verdict, our analysis, pricing model, pricing tiers, features, integrations, who it suits, who should skip it
- — re-verified summary, description, our verdict, our analysis, pricing model, pricing tiers, features, integrations, who it suits, who should skip it
Showing the 6 most recent of 22 verification passes.
Free to cite with attribution — this page re-verifies continuously.
12-month cost
Project the real annual outlay, including the implied monthly cost when only an annual tier is published.
Vendor list price only. Add-on usage, seat overages, and contract minimums are surfaced under Hidden costs & gotchas.
Plans compared
For each published Guidance tier: who it actually fits, and what it adds vs. the previous tier. Cross-reference the cost calculator above for projected annual outlay.
Open Source (MIT)
$0
Ideal for
Developers, researchers, and educators who want to study or prototype constrained decoding without a procurement conversation
What this tier adds
Starting tier — the full library under the MIT license, free, with regex/CFG constraints, the Mock model, and Transformers, llama.cpp, and OpenAI backends
Where the pricing makes sense
The company stage and team size where Guidance's pricing actually pencils out — and where peers do it cheaper.
Guidance is MIT-licensed and free — $0 forever, no seat math to model. The real cost is engineering time: a solo developer or research group prototyping grammars spends nothing but a weekend, while a funded team putting it in production should budget for owning a fork. Compare against actively maintained constrained-generation libraries before committing headcount.
Setup time & first value
How long it actually takes to get something useful out of Guidance — broken out by persona, not the marketing-page minute.
Roughly 15-30 minutes if you already have a Transformers or llama.cpp backend installed: pip install guidance, load a model, run the README chat example. Offline grammar prototyping with the Mock model takes minutes and no backend at all. Add a few hours to learn the template language, and more if you are forking to patch a backend.
Switching to or from Guidance
How to bring data in from common predecessors and how to get it back out — written for the switcher, not the buyer.
- →From plain prompting: replace free-text parses with gen(regex=...) or select() so output is valid by construction
- →From an unconstrained OpenAI call: keep OpenAI as a backend and wrap the call in gen() with your constraints
- →From a hand-rolled JSON parser: validate with grammar.match() and a CFG instead of regex-scraping the response
- ↗To an actively maintained constrained-generation library: rewrite gen()/select() calls against the new API and keep your grammar definitions
- ↗To a provider's native structured-output mode: move simple regex and select cases there and drop the dependency
- ↗To a custom internal fork: vendor the source, pin your backends, and take on the patch queue yourself
Integrations
Resources & Guides
Tutorials & Learning
YouTube returned 6 videos for “Guidance”, and we withheld 6: 6 could not be judged, because “Guidance” is a single word that other videos use for other things. We are showing none, because we could not prove any of them are about Guidance.
Official links
Tools that pair well with Guidance
Common stack mates teams adopt alongside Guidance, with the specific reason each pairing earns its keep.
Outlines
Open-source Python library that constrains LLM decoding so JSON, regex, and grammar outputs are valid on the first call.
OpenAI Cookbook
Free, MIT-licensed OpenAI API examples and Python notebooks for developers building with the OpenAI API.
Vercel AI SDK
Open-source TypeScript AI SDK for streaming AI apps and agents across 100+ models with built-in fallbacks
Alternatives to Guidance
View allOutlines
Open-source Python library that constrains LLM decoding so JSON, regex, and grammar outputs are valid on the first call.
OpenAI Cookbook
Free, MIT-licensed OpenAI API examples and Python notebooks for developers building with the OpenAI API.
Vercel AI SDK
Open-source TypeScript AI SDK for streaming AI apps and agents across 100+ models with built-in fallbacks
Frequently Asked Questions
Used Guidance? Help shape our editorial sentiment research.