Node.js + SST Example
The example below builds the BAML x86_64 Rust binaries into a Lambda layer and uses the layer in the Lambda function.Node + AWS Lambda + SST Example
View the complete example project on GitHub
Key Components
The example demonstrates how to:- Build BAML binaries - Package the BAML runtime as a Lambda layer
- Configure Lambda - Set up the Lambda function with the appropriate runtime
- Deploy with SST - Use SST to manage the deployment process
Lambda Configuration
The BAML binaries are built for x86_64 architecture and packaged as a Lambda layer. Your Lambda function references this layer to access the BAML runtime.Example SST Configuration
Runtime Requirements
Python Support
Environment Variables
When deploying to AWS Lambda, ensure you configure the necessary environment variables:- LLM API Keys - Set your OpenAI, Anthropic, or other provider API keys
- BOUNDARY_API_KEY - Optional, for Boundary Studio integration
- BAML_CACHE_DIR - Optional, to customize the cache directory location
Setting Environment Variables in SST
Best Practices
- Use Lambda Layers - Package BAML binaries as a layer to reduce deployment size
- Cache Dependencies - Leverage
BAML_CACHE_DIRfor faster cold starts - Monitor Performance - Use Boundary Studio to monitor LLM calls and performance
- Secure Secrets - Store API keys in AWS Secrets Manager or Parameter Store
Next Steps
- Check out the example repository
- Learn about environment variables
- Explore Docker deployment for containerized applications