Skip to main content
This tutorial shows how to set up Keywords AI tracing with BAML to automatically track LLM usage from your BAML client and view detailed spans in the Keywords AI platform.
Import the instrumentation module before any other module imports baml_client.b to ensure all functions are decorated.

Setup

1) Environment Variables

Create a .env or environment variables in your runtime and set:
.env

2) Create the Keywords AI BAML instrumentation module

Create a module (for example keywordsai_baml_tracing.py) that decorates all callable BAML client functions. Import this module first in your app so every BAML call is traced.
keywordsai_baml_tracing.py

3) Use the decorated BAML client

Import the decorated b from your instrumentation module and use it like your normal BAML client:
app.py

Observability

Once configured, you can view your traces and analytics in the Keywords AI platform under Signals → Traces.