# Langfuse: Cloud or Self-Hosted Setup — LLM Observability (Langfuse / LangSmith)

Source: https://www.skillbyai.com/en/llm-observability/lo-lf-setup

> Choose between Langfuse Cloud and self-hosting, create API keys and configure the Python SDK.

## What Langfuse is

**Langfuse** is an open-source LLM engineering platform: tracing, prompt management, evaluations, datasets and dashboards in one tool. You can use the managed **Langfuse Cloud** or **self-host** it, for example with Docker Compose on a single VM for a small team, or on Kubernetes for larger setups. Self-hosting matters when traces contain sensitive data that must stay in your own infrastructure or region. The self-hosted architecture uses a few components, including PostgreSQL for transactional data, ClickHouse for the high-volume trace data, Redis for queues and caching, and blob storage such as S3 for raw events; check the docs for the exact list for your version. Each project gets a **public key** and a **secret key**. The SDK reads them, plus the host URL, from environment variables. It is framework-agnostic: there are Python and JS/TS SDKs, integrations for popular frameworks, and an OpenTelemetry endpoint for everything else.

## Langfuse data path

Your code calls the SDK, the SDK batches events in a background thread, the Langfuse server ingests them, and you explore traces in the web UI.

![Four connected stages: application code, SDK background batching, Langfuse server ingestion, web UI.](assets/figures/llm-observability/section-3-map.svg) — Figure 3.1: app code -> SDK batch queue -> Langfuse server -> web UI

## Configure keys and run locally

Environment variables the Python SDK reads, and the documented quick way to start a local self-hosted instance. Never commit real keys.

```bash
# keys from Project Settings -> API Keys
export LANGFUSE_PUBLIC_KEY="pk-lf-..."
export LANGFUSE_SECRET_KEY="sk-lf-..."
export LANGFUSE_HOST="https://cloud.langfuse.com"   # or your self-hosted URL

pip install langfuse

# optional: local self-hosted instance for experiments
git clone https://github.com/langfuse/langfuse.git
cd langfuse
docker compose up
```

## Separate projects per environment

Create different Langfuse projects (and keys) for development, staging and production. Mixing test traffic with real users pollutes your dashboards and evaluation numbers, and dev keys leaked in a notebook then cannot read production data.

**Quiz:** Why might a company choose to self-host Langfuse rather than use the cloud service?

- [ ] Self-hosting is the only way to use the Python SDK
- [ ] The cloud version cannot record token usage
- [x] Trace data containing sensitive information must stay inside its own infrastructure
- [ ] Self-hosting removes the need for API keys

*Answer:* Trace data containing sensitive information must stay inside its own infrastructure. Data residency and privacy are the usual reasons. The SDK, token tracking and API keys work the same way with both options.
