> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Langfuse

> Use Langfuse observability with PraisonAI TypeScript

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
```

# Langfuse Observability

Production observability with Langfuse.

## Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export LANGFUSE_SECRET_KEY=sk-lf-...
export LANGFUSE_PUBLIC_KEY=pk-lf-...
export LANGFUSE_HOST=https://cloud.langfuse.com  # optional
```

| Variable | Required | Description |
| - | - | - |
| `LANGFUSE_SECRET_KEY` | Yes | Langfuse secret key |
| `LANGFUSE_PUBLIC_KEY` | Yes | Langfuse public key |
| `LANGFUSE_HOST` | No | Custom Langfuse host |

## Features

| Feature | Supported |
| - | - |
| Traces | ✅ |
| Spans | ✅ |
| Events | ✅ |
| Errors | ✅ |
| Metrics | ✅ |
| Export | ✅ |

## Quick Start

**1. Simple Usage**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, setObservabilityAdapter } from 'praisonai';
import { LangfuseObservabilityAdapter } from 'praisonai/observability';

// Initialize Langfuse adapter
const obs = new LangfuseObservabilityAdapter();
await obs.initialize();
setObservabilityAdapter(obs);

// Create agent with tracing
const agent = new Agent({
  name: 'TracedAgent',
  instructions: 'You are a helpful assistant.',
  llm: 'openai/gpt-4o-mini'
});

// Run with automatic tracing
const response = await agent.chat('Hello!');

// Flush traces to Langfuse
await obs.flush();
```

**2. With Configuration**

Adjust observability adapter options and agent settings for production — see the sections above.

## Multi-Agent Tracing

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, Agents, setObservabilityAdapter } from 'praisonai';
import { LangfuseObservabilityAdapter } from 'praisonai/observability';

const obs = new LangfuseObservabilityAdapter();
await obs.initialize();
setObservabilityAdapter(obs);

const researcher = new Agent({
  name: 'Researcher',
  instructions: 'Research topics.',
  llm: 'openai/gpt-4o'
});

const writer = new Agent({
  name: 'Writer',
  instructions: 'Write summaries.',
  llm: 'openai/gpt-4o-mini'
});

const agents = new AgentTeam({
  agents: [researcher, writer],
  tasks: [
    { agent: researcher, description: 'Research {topic}' },
    { agent: writer, description: 'Summarize findings' }
  ]
});

await agents.start({ topic: 'AI trends' });
await obs.flush();
```

## Troubleshooting

### Missing API Keys

```
Error: Langfuse SDK not available
```

**Solution**: Set both `LANGFUSE_SECRET_KEY` and `LANGFUSE_PUBLIC_KEY`.

### Traces Not Appearing

**Solution**: Ensure you call `await obs.flush()` before the process exits.

## Related

> [card] [Langfuse CLI Usage](https://praison.ai/docs/js/observability/langfuse-cli.md)
>
> Langfuse CLI Usage

> [card] [Observability Overview](https://praison.ai/docs/js/observability.md)
>
> Observability Overview


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.