LiteLLM
Configure LiteLLM to send traces to Laminar
Default configuration
LiteLLM is well integrated with OpenTelemetry, so you only need to specify the configuration through the environment variables.
Install the opentelemetry packages
First, install the opentelemetry packages:
install LiteLLM
For opentelemetry callback to work, you need to install LiteLLM with the proxy
extra of the LiteLLM package.
Set the environment variables
authorization
must start with a lowercase a
. This is different from
common HTTP headers convention.
Enable otel callback in the code
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 install and initialize Laminar.
Install Laminar
Initialize Laminar
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.