LiteLLM Proxy
Emit GenAI traces to Cloud & AI Cost Management from a LiteLLM proxy using its built-in OpenTelemetry callback.
"LiteLLM" refers to two different products, and how you send its cost data to Harness depends on which one you run:
LiteLLM proxy: A standalone server that routes LLM traffic for your applications. It has OpenTelemetry export built in, so you instrument the proxy once and every call routed through it emits a trace, with no application code changes. This page covers the proxy.
LiteLLM SDK: The Python library called directly in application code (
import litellm). There is no proxy to configure, so you instrument the library itself. Go to the Harness SDK integration to set it up. This page does not cover the SDK.
The proxy is configured the same way whether or not it was already exporting traces:
The proxy already exports OpenTelemetry traces to another backend.
Enable the otel callback if it is not on already, then change the endpoint and headers to the Harness values in the setup below.
The proxy does not export traces yet.
Enable the otel callback and set the Harness endpoint variables, as shown in the setup below.
You call the LiteLLM SDK in Python (import litellm), not a proxy.
Go to the Harness SDK integration instead.
Before you start, generate an ingestion token and connect a provider. Go to the AI Cost Management Quickstart for those steps. Replace <YOUR_TOKEN> below with that token and adjust the endpoint for your Harness cluster.
Instrument the LiteLLM proxy
LiteLLM proxy emits OTel traces for every LLM call via its otel callback.
Enable the callback in config.yaml:
litellm_settings:
callbacks: ["otel"]Set these environment variables on the proxy, then restart it:
export OTEL_EXPORTER="otlp_http"
export OTEL_ENDPOINT="https://app.harness.io/udp-ingest/otel/v1/traces"
export OTEL_HEADERS="Authorization=Bearer <YOUR_TOKEN>"Once the proxy restarts, every request routed through it emits traces to Harness.
What this produces:
One span per LLM call routed through the proxy.
Span attributes:
gen_ai.system,gen_ai.request.model, token usage.Cost calculated from token counts and model pricing.
Verify Traces in Cost Explorer
Send a request through the proxy so traces flow. They usually appear within a few minutes; allow up to about 20 minutes.
Go to Cloud & AI Cost Management > Cost Explorer.
Select the AI Traces view or group by Service Name, and find your service.
Select a service row to open the Service Traces drawer and inspect the span waterfall.
Next Steps
Go to Supported Providers and Frameworks to check native GenAI export support.
Go to the GenAI Span Attribute Reference to review the exact attributes CACM reads.
Go to AI Cost Troubleshooting if traces do not appear or show no cost.
Last updated
Was this helpful?