Musterby Elitery
Integrations

LiteLLM SDK

Trace LiteLLM SDK calls in Muster — `litellm.callbacks = ["langfuse_otel"]` and you're done.

This page covers the LiteLLM SDK (the Python library) — for the LiteLLM proxy see LiteLLM Proxy.

The LiteLLM SDK has built-in Muster (langfuse) telemetry. Add a callback, set credentials, and every call goes to Muster.

Setup

pip install litellm opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp
import os

os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_OTEL_HOST"] = "https://app.getmuster.io"  # optional, defaults to US

Enable the callback

import litellm

litellm.callbacks = ["langfuse_otel"]

Make a call

response = litellm.completion(
    model="gpt-3.5-turbo",
    messages=[{"role": "user", "content": "Hello!"}],
)

Enrich traces with metadata

response = litellm.completion(
    model="gpt-3.5-turbo",
    messages=[{"role": "user", "content": "Hello!"}],
    metadata={
        "generation_name": "welcome-message",
        "trace_id": "trace-123",
        "session_id": "sess-42",
        "tags": ["prod"],
    },
)

The integration constructs the OTEL endpoint from LANGFUSE_OTEL_HOST — EU, US, Japan, HIPAA, or self-hosted instances are all supported.

See also