BAML
Domain-specific language that turns LLM prompts into typed functions with reliable structured outputs.
About
Prompts become typed functions in BAML, a domain-specific language from BoundaryML in which you declare input parameters, an output schema, and a prompt template, then call the function from application code as if it were native. A Rust-based compiler generates clients for Python, TypeScript, and other languages, and schema-aligned parsing coerces model responses into the declared types even when the raw output is imperfect JSON, which makes structured extraction dependable across models. Because the model is just a configurable client, the same function runs against OpenAI, Anthropic, Google, or any local endpoint including Ollama, and switching providers is a small config change; a VS Code playground renders the exact prompt and lets you test functions without leaving the editor. The core toolchain is Apache-2.0 with no usage fees, while BoundaryML, a Y Combinator company, sells hosted observability on top. Around 8,700 GitHub stars and production adoption for extraction, classification, and agent pipelines have made it the reference implementation of schema-first prompting.
Should you use BAML?
Pick it when
Pick BAML when your team extracts or classifies structured data with LLMs from more than one language, say a Python backend plus a TypeScript service, and wants one typed schema, testable prompts, and provider swaps done in config.
Look elsewhere when
Skip it if learning a new DSL and adding a code generation step to your build is more process than the job needs. A Python-only project gets most of the benefit from Instructor with plain Pydantic models and nothing new to learn.
Alternatives to BAML
- Instructor
Plain Python and Pydantic with automatic retries on validation errors, no DSL or compiler step, but no generated clients for other languages.
- Guidance
Enforces structure during decoding with grammars and regex instead of parsing afterward, with the biggest gains on local backends like llama.cpp.
- Outlines
FSM-constrained decoding guarantees valid JSON at generation time on backends it controls, where BAML parses and coerces whatever a hosted API returns.
- Pydantic AI
A full Python agent framework with typed outputs, tools, and evals, broader than BAML but Python only and with no prompt DSL or playground.
Reviews (0)
Leave a Review
No reviews yet. Be the first to review!
Details
- Category
- AI Frameworks & Libraries
- Price
- Freemium
- Platform
- Local/Desktop
- Difficulty
- Intermediate (3/5)
- License
- Apache-2.0
- Added
- Jul 29, 2026