Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Langfuse?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ashish7802-langfuse)
# Langfuse API & SDK Skill
> **Verification Tier:** `code_example_tested` | **Last Verified:** 2026-11-18
> **Official Docs:** https://langfuse.com/docs/observability/sdk/overview
## Overview
Langfuse provides LLM observability, nested traces/generations, prompt versioning, and evaluation datasets via OpenTelemetry (`@langfuse/otel`) and the JS/Python SDKs.
## Installation
```bash
npm install langfuse @langfuse/otel @opentelemetry/sdk-node
pip install langfuse
```
## Authentication
Configure `LANGFUSE_PUBLIC_KEY` (`pk-lf-...`), `LANGFUSE_SECRET_KEY` (`sk-lf-...`), and `LANGFUSE_BASE_URL` (e.g., `https://cloud.langfuse.com`, `https://us.cloud.langfuse.com`, or your self-hosted instance). REST ingestion uses HTTP Basic Auth (`publicKey:secretKey`).
## Core Concepts
- **Traces, Spans, Generations**: Group multi-step agent runs under a single trace; record model name, input/output, and token usage on Generation observations.
- **Serverless Flushing**: Batched trace export happens asynchronously in memory. In AWS Lambda, Vercel Functions, or Cloudflare Workers, you MUST `await langfuse.flushAsync()` (or `spanProcessor.forceFlush()`) before the handler returns or traces are silently dropped.
- **Scores**: Attach automated or user-feedback evaluation scores via `traceId`.
## Error Handling & Rate Limits
- Treat telemetry failures as non-fatal: never block or crash user-facing LLM responses if Langfuse ingestion experiences transient errors or HTTP `429`.
- Configure explicit batch size and flush intervals to avoid ingestion throttling under burst traffic.
## Security Best Practices
- Mask or redact PII/secrets before sending prompt inputs/outputs to Langfuse spans.
- Keep `LANGFUSE_SECRET_KEY` strictly server-side; only use `LANGFUSE_PUBLIC_KEY` for approved client score submissions if needed.
## AI Pitfalls
- Forgetting `await flushAsync()` / `forceFlush()` in serverless handlers, resulting in zero traces appearing in the dashboard.
- Mixing up EU (`cloud.langfuse.com`) vs US (`us.cloud.langfuse.com`) `LANGFUSE_BASE_URL` regions (produces `401 Unauthorized`).
- Recording raw customer secrets or auth tokens inside trace metadata.
## Production Checklist
- [ ] `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`, and `LANGFUSE_BASE_URL` configured via env vars
- [ ] `flushAsync()` / `forceFlush()` awaited in serverless/short-lived processes
- [ ] PII scrubbing applied to logged prompt inputs
- [ ] Telemetry errors caught and isolated from critical user paths
## References
- [Langfuse SDK Overview](https://langfuse.com/docs/observability/sdk/overview)
- [Langfuse OpenTelemetry Integration](https://langfuse.com/integrations/native/opentelemetry)
## Related skills
- [`opentelemetry`](../opentelemetry/SKILL.md) — depends on
- [`openai-responses`](../openai-responses/SKILL.md) — works well with
- [`vercel-ai-sdk`](../vercel-ai-sdk/SKILL.md) — integrates with