BAML is a config file format for declaring LLM functions that you can then use in TypeScript or Python.

With BAML you can Classify or Extract any structured data using Anthropic, OpenAI or local models (using Ollama)

BAML comes with a VSCode Playground, which allows you to test prompts instantly with any LLM, without ever leaving VSCode.

Here’s a 1-min video on how BAML works seamlessly with Python (or TypeScript) to get structured outputs from LLMs:

Here’s a .baml AI function:

// example.baml
class Resume {
  name string
  skills string[]

function ExtractResume {
  input (resume_text: string)
  output Resume[]

impl<llm, ExtractResume> version1 {
  client GPT4Client // client definition not shown
  prompt #"
    Parse the following resume and return a structured representation of the data in the schema below.

    Output in this JSON format:

    Output JSON:

BAML compiles to fully typed Python and TypeScript. No matter how you change the prompt, or the LLM model, or fail-overs, the python code doesn’t change — unless you change your AI function’s signature.

The BAML compiler generates all the parsing boilerplate you need. No need to parse with json.loads ever again.

from baml_client import baml as b

async def main():
  resume = await b.ExtractResume(resume_text="""John Doe
Python, Rust
University of California, Berkeley, B.S.
in Computer Science, 2020""")

  assert == "John Doe"

BAML can be deployed to any container, with only a single package dependency required (e.g. pip install baml).

BAML VSCode Playground

Getting Started

Start by installing BAML and reading our Hello World Tutorial.

The VSCode extension provides auto-compiling on save, a realtime preview of the full prompt, syntax highlighting and great errors — every syntax error recommends a fix.

Making BAML easy to read and write is our core design philosophy.

What you get out-of-the-box

  • Typed Python/Typescript support

  • VSCode Playground — see the full prompt and run tests

  • Better code organization — no scattered jinja templates or yaml files

  • Its fast! — BAML compiles into PY and TS in less than 50ms (We ❤️ Rust)

  • Full integration with Boundary Studio — our observability dashboard

    • Turn live production data into a test-case with one click!
  • Get structured responses, 11 natively supported types, including custom classes

  • Hallucination Checks — when LLMs return something unexpected, we throw an exception

  • And best of all, everything lives in your codebase.