BAML is a domain-specific language by BoundaryML for building reliable AI workflows and agents through schema engineering, turning prompt engineering into a structured, type-safe discipline. It solves the challenge of extracting structured, validated data from LLMs by providing a declarative way to define function schemas, validate responses, and version prompts without fragile JSON parsing or boilerplate code. BAML makes the observation that most prompt engineering is really about getting the right output structure, and reframes the problem as schema definition rather than text manipulation.
BAML created the Schema-Aligned Parsing (SAP) algorithm to handle the flexible and unpredictable outputs that LLMs produce, including markdown embedded within JSON blobs and chain-of-thought reasoning before answers. Remarkably, BAML SAP combined with GPT-3.5 has been shown to outperform GPT-4o with native structured outputs in extraction benchmarks. The framework provides a playground for testing prompts in real-time, type-safe client generation for Python, TypeScript, Ruby, and Go, and versioning capabilities that let teams track and manage prompt iterations systematically.
BAML targets AI engineers and development teams building production LLM applications that require reliable structured outputs, especially in use cases like data extraction, classification, entity recognition, and automated content generation. It integrates with any LLM provider and works alongside existing codebases through generated client libraries that provide compile-time type checking and runtime validation. The framework is particularly valuable for teams who find themselves spending excessive time debugging JSON parsing errors and output format inconsistencies, offering a fundamentally different approach to LLM integration that prioritizes schema correctness over prompt wordsmithing.