langfuse-hello-world
Create a minimal working Langfuse trace example. Use when starting a new Langfuse integration, testing your setup, or learning basic Langfuse tracing patterns. Trigger with phrases like "langfuse hello world", "langfuse example", "langfuse quick start", "first langfuse trace", "simple langfuse code".
Best use case
langfuse-hello-world is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Create a minimal working Langfuse trace example. Use when starting a new Langfuse integration, testing your setup, or learning basic Langfuse tracing patterns. Trigger with phrases like "langfuse hello world", "langfuse example", "langfuse quick start", "first langfuse trace", "simple langfuse code".
Teams using langfuse-hello-world should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/langfuse-hello-world/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How langfuse-hello-world Compares
| Feature / Agent | langfuse-hello-world | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Create a minimal working Langfuse trace example. Use when starting a new Langfuse integration, testing your setup, or learning basic Langfuse tracing patterns. Trigger with phrases like "langfuse hello world", "langfuse example", "langfuse quick start", "first langfuse trace", "simple langfuse code".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Langfuse Hello World
## Overview
Create your first Langfuse trace with real SDK calls. Demonstrates the trace/span/generation hierarchy, the `observe` wrapper, and the OpenAI drop-in integration.
## Prerequisites
- Completed `langfuse-install-auth` setup
- Valid API credentials in environment variables
- OpenAI API key (for the OpenAI integration example)
## Instructions
### Step 1: Hello World with v4+ Modular SDK
```typescript
// hello-langfuse.ts
import { startActiveObservation, observe, updateActiveObservation } from "@langfuse/tracing";
import { LangfuseSpanProcessor } from "@langfuse/otel";
import { NodeSDK } from "@opentelemetry/sdk-node";
// Register OpenTelemetry processor (once at startup)
const sdk = new NodeSDK({
spanProcessors: [new LangfuseSpanProcessor()],
});
sdk.start();
async function main() {
// Create a top-level trace with startActiveObservation
await startActiveObservation("hello-world", async (span) => {
span.update({
input: { message: "Hello, Langfuse!" },
metadata: { source: "hello-world-example" },
});
// Nested span -- automatically linked to parent
await startActiveObservation("process-input", async (child) => {
child.update({ input: { text: "processing..." } });
await new Promise((r) => setTimeout(r, 100));
child.update({ output: { result: "done" } });
});
// Nested generation (LLM call tracking)
await startActiveObservation(
{ name: "llm-response", asType: "generation" },
async (gen) => {
gen.update({
model: "gpt-4o",
input: [{ role: "user", content: "Say hello" }],
output: { content: "Hello! How can I help you today?" },
usage: { promptTokens: 5, completionTokens: 10, totalTokens: 15 },
});
}
);
span.update({ output: { status: "completed" } });
});
// Allow time for the span processor to flush
await sdk.shutdown();
console.log("Trace created! Check your Langfuse dashboard.");
}
main().catch(console.error);
```
### Step 2: Hello World with `observe` Wrapper
The `observe` wrapper traces existing functions without modifying internals:
```typescript
import { observe, updateActiveObservation } from "@langfuse/tracing";
// Wrap any async function -- it becomes a traced span
const processQuery = observe(async (query: string) => {
updateActiveObservation({ input: { query } });
// Simulate processing
const result = `Processed: ${query}`;
updateActiveObservation({ output: { result } });
return result;
});
// Wrap an LLM call as a generation
const generateAnswer = observe(
{ name: "generate-answer", asType: "generation" },
async (prompt: string) => {
updateActiveObservation({
model: "gpt-4o",
input: [{ role: "user", content: prompt }],
});
const answer = "Langfuse is an open-source LLM observability platform.";
updateActiveObservation({
output: answer,
usage: { promptTokens: 10, completionTokens: 20 },
});
return answer;
}
);
// Both functions auto-nest when called within an observed context
const pipeline = observe(async () => {
await processQuery("What is Langfuse?");
await generateAnswer("Explain Langfuse in one sentence.");
});
await pipeline();
```
### Step 3: Hello World with Legacy v3 SDK
```typescript
import { Langfuse } from "langfuse";
const langfuse = new Langfuse();
async function helloLangfuse() {
const trace = langfuse.trace({
name: "hello-world",
userId: "demo-user",
metadata: { source: "hello-world-example" },
tags: ["demo", "getting-started"],
});
// Span: child operation
const span = trace.span({
name: "process-input",
input: { message: "Hello, Langfuse!" },
});
await new Promise((r) => setTimeout(r, 100));
span.end({ output: { result: "Processed successfully!" } });
// Generation: LLM call tracking
trace.generation({
name: "llm-response",
model: "gpt-4o",
input: [{ role: "user", content: "Say hello" }],
output: { content: "Hello! How can I help you today?" },
usage: { promptTokens: 5, completionTokens: 10, totalTokens: 15 },
});
await langfuse.flushAsync();
console.log("Trace URL:", trace.getTraceUrl());
}
helloLangfuse();
```
### Step 4: Python Hello World
```python
from langfuse.decorators import observe, langfuse_context
@observe()
def process_query(query: str) -> str:
return f"Processed: {query}"
@observe(as_type="generation")
def generate_response(prompt: str) -> str:
langfuse_context.update_current_observation(
model="gpt-4o",
usage={"prompt_tokens": 10, "completion_tokens": 20},
)
return "Hello from Langfuse!"
@observe()
def main():
result = process_query("Hello!")
response = generate_response("Say hello")
return response
main()
```
## Trace Hierarchy
```
Trace: hello-world
├── Span: process-input
│ input: { message: "Hello, Langfuse!" }
│ output: { result: "Processed successfully!" }
└── Generation: llm-response
model: gpt-4o
input: [{ role: "user", content: "Say hello" }]
output: "Hello! How can I help you today?"
usage: { promptTokens: 5, completionTokens: 10 }
```
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| Import error | SDK not installed | `npm install @langfuse/tracing @langfuse/otel @opentelemetry/sdk-node` |
| Auth error (401) | Invalid credentials | Verify `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` |
| Trace not appearing | Data not flushed | Call `sdk.shutdown()` (v4+) or `langfuse.flushAsync()` (v3) |
| Network error | Host unreachable | Check `LANGFUSE_BASE_URL` value |
| No auto-nesting | Missing OTel setup | Register `LangfuseSpanProcessor` with `NodeSDK` |
## Resources
- [Langfuse JS/TS SDK Cookbook](https://langfuse.com/guides/cookbook/js_langfuse_sdk)
- [TypeScript SDK Instrumentation](https://langfuse.com/docs/observability/sdk/typescript/instrumentation)
- [Python Decorators Guide](https://langfuse.com/docs/sdk/python/decorators)
- [Observation Types](https://langfuse.com/docs/observability/features/observation-types)
## Next Steps
Proceed to `langfuse-core-workflow-a` for real OpenAI/Anthropic tracing, or `langfuse-local-dev-loop` for development workflow setup.Related Skills
workhuman-hello-world
Workhuman hello world for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman hello world".
wispr-hello-world
Wispr Flow hello world for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr hello world".
windsurf-hello-world
Create your first Windsurf Cascade interaction and Supercomplete experience. Use when starting with Windsurf, testing your setup, or learning basic Cascade and Supercomplete workflows. Trigger with phrases like "windsurf hello world", "windsurf example", "windsurf quick start", "first windsurf project", "try windsurf".
webflow-hello-world
Create a minimal working Webflow Data API v2 example. Use when starting a new Webflow integration, testing your setup, or learning basic Webflow API patterns — list sites, read CMS collections, create items. Trigger with phrases like "webflow hello world", "webflow example", "webflow quick start", "simple webflow code", "first webflow API call".
vercel-hello-world
Create a minimal working Vercel deployment with a serverless API route. Use when starting a new Vercel project, testing your setup, or learning basic Vercel deployment and API route patterns. Trigger with phrases like "vercel hello world", "vercel example", "vercel quick start", "simple vercel project", "first vercel deploy".
veeva-hello-world
Veeva Vault hello world with REST API and VQL. Use when integrating with Veeva Vault for life sciences document management. Trigger: "veeva hello world".
vastai-hello-world
Rent your first GPU instance on Vast.ai and run a workload. Use when starting a new Vast.ai integration, testing your setup, or learning basic Vast.ai GPU rental patterns. Trigger with phrases like "vastai hello world", "vastai example", "vastai quick start", "rent first gpu", "vastai first instance".
twinmind-hello-world
Create your first TwinMind meeting transcription and AI summary. Use when starting with TwinMind, testing your setup, or learning basic transcription and summary patterns. Trigger with phrases like "twinmind hello world", "first twinmind meeting", "twinmind quick start", "test twinmind transcription".
together-hello-world
Run inference with Together AI -- chat completions, streaming, and model selection. Use when testing open-source models, comparing model performance, or learning the Together AI API. Trigger: "together hello world, together AI example, run llama".
techsmith-hello-world
Capture a screenshot with Snagit COM API and produce a Camtasia video. Use when automating screen captures, batch-processing recordings, or building documentation pipelines with TechSmith tools. Trigger: "techsmith hello world, snagit capture, camtasia render".
supabase-hello-world
Run your first Supabase query — insert a row and read it back. Use when starting a new Supabase project, verifying your connection works, or learning the basic insert-then-select pattern with @supabase/supabase-js. Trigger with phrases like "supabase hello world", "first supabase query", "supabase quick start", "test supabase connection", "supabase insert and select".
stackblitz-hello-world
Boot a WebContainer, mount files, install npm packages, and run a dev server in the browser. Use when learning WebContainers, building browser-based IDEs, or running Node.js without a backend server. Trigger: "stackblitz hello world", "webcontainer example", "run node in browser".