What problem does it solve?
Guidance helps you control an LLM’s output so it always matches required formats, preventing invalid or malformed responses when you need machine-readable results like JSON, XML, or code.
Core Features & Use Cases
- Regex & grammar-constrained generation: Restrict outputs to patterns or grammars so fields are syntactically valid.
- Guaranteed structured outputs: Produce correct JSON/XML/code shapes without fragile post-processing or retry loops.
- Reusable, multi-step workflows: Compose constrained steps and agent-like control flow using Pythonic functions and stateful logic.
- Token healing: Improve boundary consistency between prompt text and generated tokens to avoid formatting glitches and spacing errors.
Use cases include: extracting well-formed fields (emails, dates, IDs), generating valid API payloads, building structured data pipelines, and implementing constrained agent steps that depend on valid intermediate artifacts.
Quick Start
Ask the AI to generate a valid JSON object by constraining each field with a regex so the output is guaranteed to parse.