This page is for the LiteLLM Proxy (the gateway server). If you call LiteLLM as a Python library inside your own code, see LiteLLM (SDK) instead.
Prerequisites
- A LiteLLM Proxy you can set environment variables on.
- A LangWatch API key, from your project settings.
Setup
1
Set the environment variables on the proxy
/v1/traces to OTEL_ENDPOINT, so the spans land on https://app.langwatch.ai/api/otel/v1/traces.Self-hosted LangWatch: replace https://app.langwatch.ai with the URL of your own instance, for example export OTEL_ENDPOINT="https://langwatch.internal.example.com/api/otel". The proxy only needs network access to your LangWatch instance, so this works for proxies that are only reachable inside your VPC.2
Start the proxy
No change to your On Kubernetes, add the same variables to the proxy’s
config.yaml is needed:env (or its secret) in your Helm values.3
Send a request
Capturing prompts and responses
By default LiteLLM only exports metadata (model, tokens, cost, timing) and never the message content. To see the conversations in LangWatch, and to run evaluations on them, set:Linking proxy calls to your application traces
LiteLLM continues any trace it receives in the W3Ctraceparent header. If your application is instrumented with the LangWatch SDK or any OpenTelemetry SDK that propagates context on outgoing HTTP calls, the proxy’s spans nest inside your application’s trace, so you see your agent’s steps and the gateway call in one tree.
Sending to LangWatch and another backend
LiteLLM can export the same traces to more than one destination, for example LangWatch plus an existing Datadog or Grafana setup. See LiteLLM’s OpenTelemetry v2 docs for how to combine destinations.Older LiteLLM versions
If your proxy does not supportLITELLM_OTEL_V2 yet, use the original OpenTelemetry callback. It takes the full traces URL:
config.yaml
Troubleshooting
- No traces: check the proxy logs for exporter errors. A
401means the API key inOTEL_HEADERSis wrong or belongs to a different LangWatch instance. - Traces without messages: set
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, see above. - Self-hosted: make sure
OTEL_ENDPOINTends in/api/otel(v2) or/api/otel/v1/traces(the older callback).