The Problem with Current Approaches
Building reliable AI applications today feels like writing raw HTML in Python strings:- F-strings and string concatenation: Hard to read, easy to break
- No type safety: Runtime errors from schema mismatches
- Slow iteration: Must execute code to test prompt changes
- Manual JSON schemas: Tedious to maintain and sync with code
- Set up a complete Python environment
- Execute your entire application
- Wait for the LLM response
- Fix the prompt
- Repeat
The BAML Solution
BAML turns prompt engineering into schema engineering - where you focus on the structure of your data, not string manipulation.1. Test 10x Faster
BAML’s VSCode playground lets you test prompts directly in your editor:- See the full rendered prompt with multimodal assets
- View the exact API request being sent
- Run tests in parallel for even faster iteration
- Test in 5 seconds instead of 2 minutes
Speed matters: Faster iteration = more experiments = better prompts = better AI applications
2. Fully Type-Safe
BAML generates native types for your language:3. Works with Any Model
Switch models in seconds, not hours:- OpenAI (GPT-4, GPT-4o, O1, O3)
- Anthropic (Claude 3, Claude 3.5)
- Google (Gemini, Vertex AI)
- AWS (Bedrock)
- Azure OpenAI
- Any OpenAI-compatible API (Ollama, OpenRouter, VLLM, LMStudio, TogetherAI, Deepseek, etc.)
4. Reliable Structured Outputs
BAML’s SAP (Schema-Aligned Parsing) algorithm works even when models don’t support native tool-calling:- Handles markdown within JSON
- Supports chain-of-thought before answers
- Works on Day 1 of new model releases
- No need to check if a model supports parallel tool calls, recursive schemas,
anyOf,oneOf, etc.
BAML’s structured outputs even outperform OpenAI with their own models
5. Built-in Reliability
Add retries, fallbacks, and load balancing with simple configuration:6. Maintainable Code
Compare the readability:BAML vs Other Frameworks
vs Pydantic AI / Instructor
| Feature | BAML | Pydantic/Instructor |
|---|---|---|
| Language | Any (Python, TS, Ruby, Go) | Python only |
| Testing | Built-in playground | Run full app |
| Streaming types | Fully type-safe | Manual handling |
| Prompt previews | Live in editor | None |
| Model support | All providers | Limited |
| SAP parsing | Yes | No |
vs LangChain / LlamaIndex
| Feature | BAML | LangChain/LlamaIndex |
|---|---|---|
| Focus | Structured outputs | Chains & RAG |
| Type safety | Full | Partial |
| Testing speed | 5 seconds | 2+ minutes |
| Learning curve | Minimal | Steep |
| Vendor lock-in | None | Framework-specific |
BAML works great alongside LangChain or LlamaIndex - use BAML for structured outputs and other frameworks for orchestration.
vs Raw API Calls
| Feature | BAML | Raw APIs |
|---|---|---|
| Type safety | Generated | Manual |
| Schema sync | Automatic | Manual |
| Testing | Built-in playground | Custom setup |
| Retry logic | Built-in | Manual |
| Streaming UI | Type-safe | Manual |
| Model switching | Change 1 line | Rewrite code |
Why a New Language?
Just like we moved from string concatenation in backend code:✅ Type-safe - Catch errors before runtime
✅ Testable - Fast iteration cycle
✅ Maintainable - Easy to read and modify
✅ Language-agnostic - Works with your stack
New syntax can be incredible at expressing new ideas. The goal of BAML is to give you the expressiveness of English, but the structure of code.
Design Philosophy
-
Avoid invention when possible
- Prompts need versioning → use Git
- Prompts need storage → use filesystems
-
Any file editor and terminal should work
- No special tools required
- Works with your existing workflow
-
Be fast
- Built in Rust for maximum performance
- So fast, you can’t even tell it’s there
-
Easy to understand
- A first-year university student should be able to read BAML
- Simple syntax, powerful results
100% Open Source & Private
- Apache 2.0 License - Use it freely in commercial projects
- No telemetry - Zero network requests beyond your explicit model calls
- Not used for training - Your prompts and data stay private
- Local-first - Works completely offline (except for model calls)
- Git-friendly - BAML files diff beautifully in version control
Production Ready
BAML is used by many companies in production:- Weekly updates and improvements
- Stable API with semantic versioning
- Active community on Discord
- Comprehensive documentation
- Example projects and templates
Common Questions
Do I need to write my whole app in BAML?
No! Only write your prompts in BAML. BAML generates client code for Python, TypeScript, Ruby, Go, and REST APIs that integrates seamlessly with your existing application.Is BAML production-ready?
Yes! Many companies use BAML in production. We ship updates weekly and maintain backward compatibility.Can I use BAML with my existing framework?
Yes! BAML works great alongside LangChain, LlamaIndex, or any other framework. Use BAML for structured outputs and your preferred framework for orchestration.What if I need to switch models at runtime?
BAML has you covered! Check out the Client Registry to dynamically select models based on runtime conditions.Get Started
Quick Start
Install BAML and create your first function in 5 minutes
Try Online
Test BAML in your browser without installing anything
Examples
See BAML in action with interactive examples
Join Discord
Get help from the community and BAML team