Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Install and configure Langfuse SDK authentication for LLM observability. Use when setting up a new Langfuse integration, configuring API keys, or initializing Langfuse tracing in your project. Trigger with phrases like "install langfuse", "setup langfuse", "langfuse auth", "configure langfuse API key", "langfuse tracing setup".
.claude/skills/jeremylongshore-langfuse-install-auth/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | -14% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 74% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 13% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 33% | 0% |
Install the Langfuse SDK and configure authentication for LLM observability. Covers both the legacy langfuse package (v3) and the modern modular SDK (v4+/v5) built on OpenTelemetry.
pk-lf-...) and Secret Key (sk-lf-...) from project settingsTypeScript/JavaScript (v4+ modular SDK -- recommended):
bashset -euo pipefail # Core client for prompt management, datasets, scores npm install @langfuse/client # Tracing (observe, startActiveObservation) npm install @langfuse/tracing @langfuse/otel @opentelemetry/sdk-node # OpenAI integration (drop-in wrapper) npm install @langfuse/openai # LangChain integration npm install @langfuse/langchain
TypeScript/JavaScript (v3 legacy -- single package):
bashnpm install langfuse
Python:
bashpip install langfuse
pk-lf-... (identifies your project)sk-lf-... (grants write access -- keep secret)https://cloud.langfuse.com)bash# Set environment variables export LANGFUSE_PUBLIC_KEY="pk-lf-..." export LANGFUSE_SECRET_KEY="sk-lf-..." export LANGFUSE_BASE_URL="https://cloud.langfuse.com" # Or create .env file cat >> .env << 'EOF' LANGFUSE_PUBLIC_KEY=pk-lf-your-public-key LANGFUSE_SECRET_KEY=sk-lf-your-secret-key LANGFUSE_BASE_URL=https://cloud.langfuse.com EOF
> Note: v4+ uses LANGFUSE_BASE_URL. Legacy v3 uses LANGFUSE_HOST or LANGFUSE_BASEURL.
typescript// src/lib/langfuse.ts import { LangfuseClient } from "@langfuse/client"; import { startActiveObservation } from "@langfuse/tracing"; import { LangfuseSpanProcessor } from "@langfuse/otel"; import { NodeSDK } from "@opentelemetry/sdk-node"; // 1. Register the OpenTelemetry span processor (once at app startup) const sdk = new NodeSDK({ spanProcessors: [new LangfuseSpanProcessor()], }); sdk.start(); // 2. Create the Langfuse client for prompt/dataset/score operations export const langfuse = new LangfuseClient({ publicKey: process.env.LANGFUSE_PUBLIC_KEY, secretKey: process.env.LANGFUSE_SECRET_KEY, baseUrl: process.env.LANGFUSE_BASE_URL, }); // 3. Verify connection async function verify() { await startActiveObservation("connection-test", async (span) => { span.update({ input: { test: true } }); span.update({ output: { status: "connected" } }); }); console.log("Langfuse connection verified. Check dashboard for trace."); } verify();
typescriptimport { Langfuse } from "langfuse"; const langfuse = new Langfuse({ publicKey: process.env.LANGFUSE_PUBLIC_KEY, secretKey: process.env.LANGFUSE_SECRET_KEY, baseUrl: process.env.LANGFUSE_HOST, }); // Verify with a test trace const trace = langfuse.trace({ name: "connection-test", metadata: { test: true }, }); await langfuse.flushAsync(); console.log("Connected. Trace URL:", trace.getTraceUrl()); // Clean shutdown process.on("beforeExit", async () => { await langfuse.shutdownAsync(); });
pythonfrom langfuse import Langfuse import os langfuse = Langfuse( public_key=os.environ["LANGFUSE_PUBLIC_KEY"], secret_key=os.environ["LANGFUSE_SECRET_KEY"], host=os.environ.get("LANGFUSE_HOST", "https://cloud.langfuse.com"), ) # Test trace trace = langfuse.trace(name="connection-test", metadata={"test": True}) langfuse.flush() print(f"Connected. Trace: {trace.get_trace_url()}")
| Feature | v3 (langfuse) | v4+ (@langfuse/*) | |---------|-----------------|---------------------| | Package | Single langfuse | Modular: @langfuse/client, @langfuse/tracing, @langfuse/otel | | Base URL env var | LANGFUSE_HOST | LANGFUSE_BASE_URL | | Tracing | langfuse.trace() | startActiveObservation() / observe() | | Client class | Langfuse | LangfuseClient | | OpenAI wrapper | observeOpenAI() from langfuse | observeOpenAI() from @langfuse/openai | | Foundation | Custom | OpenTelemetry |
| Error | Cause | Solution | |-------|-------|----------| | 401 Unauthorized | Invalid or expired API key | Re-check keys in Langfuse dashboard Settings > API Keys | | ECONNREFUSED | Wrong host URL or server down | Verify LANGFUSE_BASE_URL / LANGFUSE_HOST | | Missing required configuration | Env vars not loaded | Ensure dotenv/config imported at entry point | | Module not found | Package not installed | Run npm install or pip install again | | Using pk- key as secret | Keys swapped | Public key starts pk-lf-, secret starts sk-lf- |
After auth is working, proceed to langfuse-hello-world for your first traced LLM call.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-06 | pass→pass | 16,136 | 16,377 | +1% | 1 | 1 | 0% | 2,061 | 3,792 | +84% | 0 | 0 | — |
case-07 | fail→pass | 21,810 | 10,138 | -54% | 1 | 1 | 0% | 3,209 | 2,774 | -14% | 0 | 0 | — |
case-01 | fail→pass | 19,432 | 14,887 | -23% | 1 | 1 | 0% | 2,723 | 3,736 | +37% | 0 | 0 | — |
case-02 | fail→pass | 16,789 | 16,602 | -1% | 1 | 1 | 0% | 2,293 | 3,987 | +74% | 0 | 0 | — |
case-03 | fail→pass | 22,143 | 14,220 | -36% | 1 | 1 | 0% | 3,281 | 3,700 | +13% | 0 | 0 | — |
case-04 | pass→pass | 17,722 | 16,508 | -7% | 1 | 1 | 0% | 2,341 | 3,981 | +70% | 0 | 0 | — |
case-05 | pass→pass | 18,200 | 26,075 | +43% | 1 | 1 | 0% | 2,569 | 5,820 | +127% | 0 | 0 | — |
case-08 | fail→pass | 15,049 | 9,361 | -38% | 1 | 1 | 0% | 1,957 | 2,594 | +33% | 0 | 0 | — |
case-09 | pass→pass | 11,080 | 8,799 | -21% | 1 | 1 | 0% | 935 | 2,389 | +156% | 0 | 0 | — |
case-10 | fail→pass | 19,689 | 8,454 | -57% | 1 | 1 | 0% | 2,251 | 2,158 | -4% | 0 | 0 | — |
case-11 | fail→pass | 22,457 | 5,107 | -77% | 1 | 1 | 0% | 2,484 | 2,613 | +5% | 0 | 0 | — |
case-12 | fail→pass | 17,434 | 13,691 | -21% | 1 | 1 | 0% | 2,521 | 3,640 | +44% | 0 | 0 | — |
case-13 | pass→pass | 8,440 | 7,928 | -6% | 1 | 1 | 0% | 1,140 | 2,039 | +79% | 0 | 0 | — |
case-14 | fail→pass | 14,739 | 8,214 | -44% | 1 | 1 | 0% | 1,352 | 2,254 | +67% | 0 | 0 | — |
case-15 | fail→pass | 26,474 | 3,751 | -86% | 1 | 1 | 0% | 3,066 | 2,182 | -29% | 0 | 0 | — |
case-16 | pass→pass | 16,174 | 14,994 | -7% | 1 | 1 | 0% | 2,767 | 3,531 | +28% | 0 | 0 | — |
case-17 | pass→pass | 13,177 | 7,492 | -43% | 1 | 1 | 0% | 1,895 | 3,008 | +59% | 0 | 0 | — |
case-18 | pass→pass | 14,758 | 5,214 | -65% | 1 | 1 | 0% | 1,391 | 2,691 | +93% | 0 | 0 | — |
case-19 | pass→pass | 10,879 | 7,136 | -34% | 1 | 1 | 0% | 1,721 | 2,010 | +17% | 0 | 0 | — |
case-20 | fail→pass | 14,320 | 7,409 | -48% | 1 | 1 | 0% | 1,714 | 2,133 | +24% | 0 | 0 | — |
case-21 | fail→pass | 15,819 | 8,277 | -48% | 1 | 1 | 0% | 1,502 | 1,978 | +32% | 0 | 0 | — |
case-22 | pass→pass | 9,376 | 4,929 | -47% | 1 | 1 | 0% | 1,234 | 2,355 | +91% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +55 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.