Default configuration

LiteLLM is well integrated with OpenTelemetry, so you only need to specify the configuration through the environment variables.

1

Set the environment variables

LMNR_PROJECT_API_KEY="<your-project-api-key>"
OTEL_EXPORTER="otlp_grpc"
OTEL_ENDPOINT="https://api.lmnr.ai:8443"
OTEL_HEADERS="authorization=Bearer $LMNR_PROJECT_API_KEY"

authorization must start with a lowercase a. This is different from common HTTP headers convention.

2

Enable otel callback in the code

litellm.callbacks = ['otel']
3

Run your code and see traces in Laminar

Using Laminar’s features

If you want to use Laminar’s features, such as sessions, manual spans, observe decorator, you will need to initialize Laminar.

from lmnr import Laminar
Laminar.initialize(project_api_key="LMNR_PROJECT_API_KEY")

Laminar should be initialized once in your application. This could be at the server startup, or in the entry point of your application.

This will automatically instrument all major LLM provider SDKs, LLM frameworks including LangChain and LlamaIndex, and calls to vector databases.

In some Node JS setups, you may need to manually pass the modules you want to instrument, such as OpenAI. See the section on manual instrumentation.

For more information, refer to the instrumentation docs.

This, however, will most likely result in your LLM calls being double-traced – once by LiteLLM and once by Laminar. To avoid this, you can disable automatic Laminar instruments at initialization.

Laminar.initialize(instruments=set())