BAML Documentation — Structured Outputs from Any LLM
by BoundaryML
Define LLM functions with real types and get reliable structured output — even from models with no function-calling API.
Overview
BAML (Boundary AI Markup Language) is an Apache-2.0 licensed DSL for LLM functions: you declare a function's input variables and its return type in a .baml file, and BAML compiles it into type-safe clients you can call from TypeScript, Python, Go, C#, Java and Ruby. Its distinguishing piece is Schema-Aligned Parsing (SAP), an algorithm that recovers structured data from imperfect model output — repairing broken JSON with missing brackets or trailing commas, extracting objects wrapped in Markdown code fences, skipping past chain-of-thought preamble from reasoning models like DeepSeek-R1, and coercing types where the model returns "123" instead of 123. That means structured output works against any LLM, including open-source models with no native function-calling or JSON-mode API, rather than only the providers that ship a constrained-decoding endpoint. The developer experience is built around a VSCode playground with hot reloading, so you iterate on a prompt and see typed results without a rebuild cycle, plus streaming of partial structured data and a built-in testing framework. The docs at this URL cover BAML v0, the established DSL; BAML v1 — a fuller programming language with a runtime type system, static error analysis, green-thread concurrency, built-in evals and an agent-oriented standard library — is in public beta with its own documentation. Adoption is incremental: you can add a single BAML function to an existing codebase and call it from your current language.
At a Glance
- Topic
- Frameworks
- Level
- Intermediate
- Format
- Documentation
- Cost
- Free
- Duration
- ~2-3 hours to work through the quickstart and language reference
- Provider
- BoundaryML
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Define typed LLM functions in .baml files and generate type-safe clients for Python, TypeScript, Go, Java, C# and Ruby
- ✓Use Schema-Aligned Parsing to get valid structured output from models that return malformed or Markdown-wrapped JSON
- ✓Get structured output from open-source models that have no native function-calling or JSON-mode API
- ✓Iterate on prompts in the VSCode playground with hot reloading instead of rebuild-and-rerun cycles
- ✓Stream partial structured objects to a UI before the model finishes generating
- ✓Write tests for LLM functions and swap providers without rewriting call sites
Highlights
- •Schema-Aligned Parsing repairs real-world model output instead of assuming perfectly formed JSON
- •Provider- and language-agnostic: any LLM, any of six client languages, any schema
- •VSCode playground with hot reload — an unusually tight prompt-iteration loop
- •Apache 2.0 and incrementally adoptable; BAML v1 with built-in evals and agent tooling is in public beta
Who It’s For
Best For
- ✓Engineers building document/PDF extraction pipelines that must produce validated records
- ✓Agent developers who need dependable tool arguments and typed intermediate results
- ✓Teams serving open-source models that lack a structured-output API
- ✓Polyglot codebases that call LLMs from more than one language
Prerequisites
- •Working knowledge of at least one of Python, TypeScript, Go, Java, C# or Ruby
- •Basic LLM prompting experience and familiarity with JSON schemas
FAQ
What is BAML Documentation — Structured Outputs from Any LLM?
Official documentation for BAML, BoundaryML's open-source domain-specific language for defining typed LLM functions and getting reliable structured outputs. It is for engineers tired of hand-parsing malformed JSON out of model responses across extraction, RAG and agent workloads.
Is BAML Documentation — Structured Outputs from Any LLM free?
BAML Documentation — Structured Outputs from Any LLM is free to access.
What level is BAML Documentation — Structured Outputs from Any LLM for?
BAML Documentation — Structured Outputs from Any LLM is aimed at a intermediate audience. Recommended background: Working knowledge of at least one of Python, TypeScript, Go, Java, C# or Ruby, Basic LLM prompting experience and familiarity with JSON schemas.
How long does BAML Documentation — Structured Outputs from Any LLM take?
Expect roughly ~2-3 hours to work through the quickstart and language reference. Most learners work through it at their own pace.
What will I learn from BAML Documentation — Structured Outputs from Any LLM?
You'll learn: Define typed LLM functions in .baml files and generate type-safe clients for Python, TypeScript, Go, Java, C# and Ruby; Use Schema-Aligned Parsing to get valid structured output from models that return malformed or Markdown-wrapped JSON; Get structured output from open-source models that have no native function-calling or JSON-mode API; Iterate on prompts in the VSCode playground with hot reloading instead of rebuild-and-rerun cycles; Stream partial structured objects to a UI before the model finishes generating; Write tests for LLM functions and swap providers without rewriting call sites.