Choose Your Language
BAML works with Python, TypeScript, Ruby, Go, and any language via REST API.
.baml filesbaml_client on saveThe extension works with VSCode, Cursor, and other VSCode-compatible editors. JetBrains and Neovim support coming soon.
Python (pip)
Python (poetry)
Python (uv)
TypeScript (npm)
TypeScript (pnpm)
TypeScript (yarn)
TypeScript (bun)
baml_src/ - Directory for your BAML filesbaml_src/main.baml - Example functionbaml_src/clients.baml - LLM client configurationsbaml_src/generators.baml - Code generation settingsclass Receipt {
establishment_name string
date string @description("ISO8601 formatted date")
total int
currency string
items Item[]
}
class Item {
name string
price float
quantity int
}
function ExtractReceipt(receipt: image | string) -> Receipt {
client GPT4o
prompt #"
{{ _.role("user") }}
Extract info from this receipt:
{{ receipt }}
{{ ctx.output_format }}
"#
}
test ReceiptTest {
functions [ExtractReceipt]
args {
receipt #"
Starbucks
Date: 2024-03-15
Total: $12.50 USD
Items:
- Coffee $4.50 x 2
- Croissant $3.50 x 1
"#
}
}
client<llm> GPT4o {
provider openai
options {
model gpt-4o
api_key env.OPENAI_API_KEY
}
}
client<llm> Claude {
provider anthropic
options {
model claude-3-haiku-20240307
api_key env.ANTHROPIC_API_KEY
max_tokens 1000
}
}
baml_client/ - Auto-generated client codeOpen any
.baml file in VSCode and click the “Open Playground” button above your function, or use the command palette (Cmd/Ctrl + Shift + P) and search for “BAML Playground”.What You Get
Type Safety
Full autocomplete and type checking in your IDE. BAML generates Pydantic models (Python) or TypeScript interfaces.
Streaming Support
Stream partial responses with type-safe intermediate states.
Built-in Testing
Test functions directly in VSCode without running your app.
Multiple Models
Easily switch between OpenAI, Anthropic, Gemini, and more.
Next Steps
Add Retries & Fallbacks
Make your functions more reliable
Use Images & PDFs
Process multimodal inputs
Build an Agent
Create stateful AI workflows
Common Issues
Python autocomplete not working? Add this to your VSCode settings:
Get Help
- Join our Discord community
- Check out Interactive Examples
- Read the full documentation
- Try Prompt Fiddle online