BAML
BAML is a domain-specific language for writing LLM functions that return type-safe structured outputs and are version-controlled and testable alongside application code.
Description
BAML is a domain-specific language for defining and testing LLM functions. Each prompt becomes a typed function that produces structured outputs from an LLM, with generated client code that calls the endpoint, parses the output, fixes broken JSON, and handles errors. Prompts are version controlled with the application code and can be viewed and run directly within the editor. BAML works across model providers, including open-source models, and is released under Apache 2.0.
Solution
A developer declares an LLM function in BAML with a typed return shape and prompt. BAML generates client code that sends the prompt to the configured model, parses the response, repairs malformed JSON, and returns a typed value to the application. The function can be run and tested directly in the editor, and lives in source control with the rest of the code.
Primary use cases
- defining LLM functions as typed code
- extracting type-safe structured outputs from LLMs
- version-controlling and testing prompts with application code
- running prompts directly in the editor
Open the full interactive page →
Diagram, neighbourhood map, code examples, related patterns and full provenance.