baml dev command starts a development server that watches your BAML source files for changes, automatically reloads the runtime, regenerates client code, and exposes your BAML functions via HTTP endpoints.
Usage
Options
Path to the directory containing your BAML source files.
Port number for the HTTP server.
Load environment variables from a
.env file. Disable with --no-dotenv.Path to a custom environment file. If not specified, looks for
.env in the current directory.Enable specific features (can be specified multiple times).Available features:
beta- Enable beta features and suppress experimental warningsdisplay_all_warnings- Show all warnings in CLI output
What It Does
Thebaml dev command combines the functionality of baml serve with automatic reloading:
- Starts HTTP server - Exposes BAML functions as REST endpoints on the specified port
-
Watches for changes - Monitors all files in
baml_src/for modifications -
Auto-regenerates code - Runs
baml generatewhenever BAML files change - Hot reloads runtime - Updates the running server with new function definitions without restart
- Provides debugging endpoints - Swagger UI, OpenAPI spec, and health checks
File Watching
The dev server uses efficient file watching with:- 200ms debounce - Groups rapid file changes to avoid excessive reloads
- Recursive watching - Monitors all subdirectories in
baml_src/ - Automatic detection - Picks up new files, deletions, and modifications
Examples
Start with default settings
Start the dev server on port 2024:Use a custom port
Specify BAML source directory
Use custom environment file
Enable beta features
HTTP Endpoints
Once running, the dev server exposes:Function Endpoints
POST /call/:function_name - Call a BAML function
POST /stream/:function_name - Stream results from a BAML function
Debugging Endpoints
GET /docs - Interactive Swagger UI documentation
Open http://localhost:2024/docs in your browser to:
- Browse all available functions
- Test function calls interactively
- View request/response schemas
GET /openapi.json - OpenAPI specification
GET /_debug/ping - Health check endpoint
GET /_debug/status - Server status and authentication check
Hot Reload Behavior
When you save a BAML file:- Change detected (200ms debounce window)
- Runtime reloads
- Server continues running with updated function definitions
Development Workflow
Typical development workflow withbaml dev:
1. Start the server
2. Open Swagger UI
Navigate to http://localhost:2024/docs in your browser.3. Edit BAML files
Modifybaml_src/functions.baml:
4. See automatic reload
5. Test immediately
In Swagger UI or via curl:6. Iterate quickly
Modify prompt, add fields, change logic - changes are reflected immediately without manual restart.Authentication
The dev server supports optional authentication via thex-baml-api-key header.
Enable authentication
Set theBAML_PASSWORD environment variable:
.env:
Make authenticated requests
Troubleshooting
Port already in use
Error: “Failed to bind to port 2024” Solution: Use a different port:Changes not detected
Issue: File changes don’t trigger reload Solution:- Ensure you’re editing files inside
baml_src/ - Check file permissions allow reading
- Save the file (some editors use atomic writes that may cause issues)
- Try restarting the dev server
Reload failures
Error: “Failed to reload runtime: Parser error” Solution: Fix the syntax error in your BAML file. The server continues running with the last valid configuration. Check the error message for:- Line number of the error
- Specific syntax issue
- File containing the problem
API key errors when testing
Error: 401 Unauthorized or “Missing API key” Solution: Ensure LLM provider API keys are set:Memory issues with many changes
Issue: Server slows down or crashes after many reloads Solution: Restart the dev server periodically:Comparison with baml serve
| Feature | baml dev | baml serve |
|---|---|---|
| HTTP endpoints | ✓ | ✓ |
| File watching | ✓ | ✗ |
| Auto reload | ✓ | ✗ |
| Auto regenerate | ✓ | ✗ |
| Production use | ✗ | ✓ |
| Stability | Development | Production |
baml dev for:
- Local development
- Rapid iteration
- Testing changes immediately
baml serve for:
- Production deployments
- Stable API endpoints
- When you don’t need hot reload
Related Commands
baml serve- Production HTTP server without hot reloadbaml generate- Manually generate client codebaml test- Run automated testsbaml init- Initialize a new BAML project