Full-Code · Agent SDKsactive

BAML

Type: full-code · Vendor: Boundary (BoundaryML) · Language: Rust · License: Apache-2.0 · Status: active · Status in practice: emerging · First released: 2023-10-01

Links: homepage docs repo

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.

Agent loop shape. 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

Key concepts

  • LLM function own-your-prompts (docs)BAML's central unit: a named function with typed parameters, a typed return shape, a client, and a prompt template, compiled into a generated client your application calls like an ordinary function.
  • Schema-Aligned Parsing (SAP) structured-output (docs)BAML's Rust parser that reads whatever the model returns and coerces it into the declared schema, fixing markdown fences, trailing commas, and unquoted values instead of requiring strictly valid JSON.
  • baml_client structured-output (docs)The generated client package BAML emits for your target language (Python, TypeScript, Ruby, Go, and more) that wraps each LLM function with type-safe call, parse, and error handling.
  • test block eval-harness (docs)An in-file test case for an LLM function with fixed inputs and @@assert / @@check expectations, runnable in the VSCode/JetBrains playground or via the BAML CLI.

Patterns this full-code implements —

Neighbourhood

Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.