Self-hosted MicroVM sandbox service for AI agents, with fast starts, hardware isolation and E2B SDK compatibility.

Guidance
Python library for steering language models, combining constrained generation with ordinary control flow so outputs follow regexes, grammars or JSON schemas.
What is Guidance?
Guidance is an open-source Python library for controlling how a language model produces its output. Instead of hoping a free-form prompt returns the right shape, you write a program that mixes prompt text, Python logic and generation calls. A gen() call can be constrained with a regular expression, select() picks from a fixed list of options, and any context-free grammar can be enforced, so a JSON schema or a Pydantic model becomes a hard constraint on the result. Because a grammar often fixes some tokens in advance, Guidance can insert them itself and skip model forward passes, which the project says reduces latency and cost against conventional prompting. You install it from PyPI with pip install guidance, and it works with backends including Transformers, llama.cpp and OpenAI. Custom building blocks are made with the @guidance decorator, and a Mock model lets you test grammars offline without API calls. The library is free and released under the MIT license.
Use cases
- Constrain model output with grammars
- Generate JSON that matches a Pydantic model
- Mix Python logic with generation
- Select among fixed options with an LLM
- Capture generated text into named variables
- Test grammars offline with a mock model
Who it's for
Why use Guidance
- Constrained generation makes the output format predictable, which suits parsing JSON or fixed answers.
- Writing prompts as Python programs lets you use loops, conditionals and tool use alongside generation.
- Fast-forwarding fixed tokens can cut model passes, which lowers latency and GPU use.
- It works across local and hosted backends, so the same program can move between models.
Guidance features
- gen() with regex constraints
- select() for choosing among fixed options
- Context-free grammar constraints
- JSON output from a schema or Pydantic model
- Custom functions with the @guidance decorator
- Fast-forwarding of tokens known from the grammar
- Mock model for offline grammar debugging
- Jupyter notebook widget for richer output
- Backends including Transformers, llama.cpp and OpenAI
Guidance integrations
How to get started with Guidance
- Install it with pip install guidance, along with the backend your model needs.
- Load a model object such as Transformers("microsoft/Phi-4-mini-instruct") or a llama.cpp model.
- Build the conversation with system(), user() and assistant() blocks and append text to the model object.
- Add gen() or select() calls with a regex, a grammar or a JSON schema to constrain the output.
- Read results back by name, such as lm["lm_response"], and test grammars with the Mock model.
Guidance limitations
- A library for developers, not an end-user app
- Full grammar constraints need a backend model with full support for Guidance
- Its programming style has a learning curve compared with plain prompting
Guidance pricing
Guidance 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.
Guidance alternatives
The main Guidance alternatives listed on Debuly are Outlines, BAML, Instructor, LMQL, TypeChat and Chroma. The table compares pricing and platforms; order is A–Z.
| Tool | Pricing | Starting price | Platforms |
|---|---|---|---|
| Guidance | Open source | — | API |
| BAML | Open source | — | CLI, macOS, Linux, Windows |
| Chroma | Open source | $250/mo | API, CLI, Self-hosted, Web |
| Instructor | Open source | — | API, Self-hosted |
| LMQL | Open source | — | Python, CLI, Web, Self-hosted |
| Outlines | Open source | — | API |
| TypeChat | Open source | — | — |

BAML
Open-source, TypeScript-like programming language for agents, with typed LLM functions, built-in tests and SDK generation.
Open sourceVisit BAML (official site)
Chroma
Open-source search database for AI apps, with vector, full-text, regex and metadata search and a serverless cloud option.
Open sourceVisit Chroma (official site)
Instructor
Open-source library that gets validated, typed structured data out of LLMs using Pydantic models and automatic retries.
Open sourceVisit Instructor (official site)LMQL
Programming language from ETH Zurich for LLM prompting that adds Python control flow, typed variables and hard output constraints.
Open sourceVisit LMQL (official site)
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 sourceVisit Outlines (official site)
TypeChat
Microsoft library that builds natural-language interfaces by using your own types to define what a model must return.
Open sourceVisit TypeChat (official site)
Guidance FAQ
Is Guidance free?
Yes. The library is released under the MIT license and installs from PyPI. No paid plans are listed, though a hosted model backend may charge for its own use.
Which models does Guidance work with?
The README says it supports a variety of backends, including Transformers, llama.cpp and OpenAI. Full grammar constraints depend on the backend having full support for Guidance.
Can Guidance produce JSON?
Yes. A JSON schema is a context-free grammar, so gen_json can constrain a model to a schema or Pydantic model and the result can be loaded with json.loads or validated by Pydantic.
How do I install Guidance?
Run pip install guidance. If you already have the backend your model needs, no extra setup is described.
Who is Guidance for?
Developers and researchers who need predictable, structured output from language models, particularly those who prefer writing Python to long prompts.
What are alternatives to Guidance?
Alternatives include Outlines, BAML, Instructor and LMQL, which also help produce structured LLM output.
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.
| Source | Type | Accessed |
|---|---|---|
| github.com/guidance-ai/guidance | official |
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.



