Getting Started with BAML
Welcome to BAML! This tutorial will walk you through setting up your first project and creating a simple AI function.
Prerequisites
Before you begin, make sure you have:
- Node.js 18+ or Python 3.9+
- An API key from OpenAI, Anthropic, or another supported provider
Installation
- npm
- pip
npm install @boundaryml/baml
pip install baml-py
Your First BAML Function
Create a file called main.baml:
function ClassifySentiment(text: string) -> Sentiment {
client GPT4
prompt #"
Classify the sentiment of this text:
{{ text }}
Respond with: positive, negative, or neutral
"#
}
enum Sentiment {
positive
negative
neutral
}
client<llm> GPT4 {
provider openai
model gpt-4
}
Next Steps
- Learn about the BAML type system to understand how structured outputs work
- Explore the Cookbook for more classification examples
- Check the Reference for complete syntax documentation
tip
Try the Interactive Tour for hands-on learning!