Skip to main content

Langtrace

Open-source observability and evaluations for LLM applications, at langtrace.ai.

info

We want to learn how we can make the callbacks better! Meet the LiteLLM founders or join our discord

Pre-Requisites​

uv add litellm

Langtrace ingests OTLP at a custom path (/api/trace) with an x-api-key header, whereas OpenTelemetry v2 exports to /v1/traces with no Langtrace credentials. With LITELLM_OTEL_V2=true, run an OpenTelemetry Collector between them: litellm exports to the collector, and the collector forwards the spans to Langtrace with your key. The langtrace preset applies Langtrace's attribute schema; the collector only handles delivery, which is why LANGTRACE_API_KEY lives in the collector's environment rather than the proxy's

Without LITELLM_OTEL_V2, the langtrace callback posts directly to https://app.langtrace.ai/api/trace with LANGTRACE_API_KEY set on the proxy as the x-api-key header, no collector needed. Set LANGTRACE_API_HOST to the base URL of a self-hosted Langtrace (for example https://langtrace.example.com) and the callback posts to <host>/api/trace. See the proxy logging guide for that setup

Quick Start​

import litellm
import os

os.environ["LITELLM_OTEL_V2"] = "true"
os.environ["OTEL_ENDPOINT"] = "http://otel-collector:4318"
# LLM API Keys
os.environ["OPENAI_API_KEY"] = ""

# set langtrace as a callback, litellm will send the data to langtrace
litellm.callbacks = ["langtrace"]

# openai call
response = litellm.completion(
model="gpt-5.6-terra",
messages=[
{"role": "user", "content": "Hi 👋 - i'm openai"}
]
)

What Langtrace renders​

Open the Langtrace UI; the spans flow through your collector carrying the langtrace.* and llm.* keys alongside the canonical gen_ai.* ones.

The langtrace mapper adds langtrace.service.name for the provider, request and response identifiers (llm.model, gen_ai.response.model, gen_ai.response_id, gen_ai.system_fingerprint), the request params (llm.temperature, top_p, top_k, max_tokens, frequency_penalty, presence_penalty), the llm.stream flag, the llm.token.counts.* usage split, and llm.prompts / llm.completions when content capture is on. See the full attribute table.

LiteLLM trace in Langtrace

Full OpenTelemetry reference​

This page covers the Langtrace-specific setup. For span attributes, prompt and response capture, metrics, distributed tracing, and which routes are traced, see the OpenTelemetry v2 guide.

Support & Talk to Founders​

LiteLLM Enterprise
SSO/SAML, audit logs, spend tracking, multi-team management, and guardrails, built for production.
Learn more →