What is BAML?
BAML is a domain-specific language to write and test LLM functions.
In BAML, prompts are treated like functions. An LLM function is a prompt template with some defined input variables, and a specific output type like a class, enum, union, optional string, etc.
With BAML you can write and test a complex LLM function in 1/10 of the time it takes to setup a python LLM testing environment.
Try it out in the playground — PromptFiddle.com
Share your creations and ask questions in our Discord.
Demo video
Features
Language features
- Plugs into any language: BAML functions can be called from any language.
- JSON correction: BAML fixes bad JSON returned by LLMs (e.g. unquoted keys, newlines, comments, extra quotes, and more)
- Wide model support: Ollama, Openai, Anthropic, Gemini. Tested on small models like Llama2
- Streaming: Stream structured partial outputs
- Resilience and fallback features: Add retries, redundancy, to your LLM calls
Developer Experience
- Stability: BAML works the same in EVERY language we support. No more “it works in python but not in Typescript”
- Type safety: BAML is a typed language, so you get type errors before you run your LLM, and autocomplete in your IDE
- Realtime Prompt Previews: See the full prompt always, even if it has loops and conditionals
- Testing support: Test functions in the playground with 1 click
Production features
- Observability Platform: Use Boundary Studio to visualize your functions and replay production requests with 1 click
BAML in the wild
- Zenfetch - ChatGPT for your bookmarks
- Vetrec - AI-powered Clinical Notes for Veterinarians
- MagnaPlay - Production-quality machine translation for games
- Aer Compliance - AI-powered compliance tasks
- Haven - Automate Tenant communications with AI
- Muckrock - FOIA request tracking and filing
- and more! Let us know if you want to be showcased or want to work with us 1-1 to solve your usecase.
Starter projects
First steps
We recommend checking the examples in PromptFiddle.com. Once you’re ready to start, install the toolchain and read the guides.