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

# Langfuse

> Trace TokenLab OpenAI-compatible requests with Langfuse

## Overview

Langfuse can trace TokenLab calls through its OpenAI integration when the OpenAI SDK is configured with TokenLab's `/v1` base URL.

<Note>
  **Type**: Observability

  **Primary Path**: OpenAI SDK tracing

  **Support Confidence**: Supported OpenAI-compatible tracing path
</Note>

## Environment

```bash theme={null}
export LANGFUSE_SECRET_KEY="sk-lf-..."
export LANGFUSE_PUBLIC_KEY="pk-lf-..."
export LANGFUSE_BASE_URL="https://cloud.langfuse.com"
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
```

## Example

```python theme={null}
import os

from langfuse import observe
from langfuse.openai import openai

openai.api_key = os.environ["TOKENLAB_API_KEY"]
openai.base_url = "https://api.tokenlab.sh/v1"


@observe()
def story():
    return openai.chat.completions.create(
        model="claude-sonnet-5",
        messages=[{"role": "user", "content": "Write a short haiku."}],
    ).choices[0].message.content
```

## Endpoint Notes

This page covers Langfuse tracing for the OpenAI SDK path. If your application uses TokenLab native Responses, Anthropic Messages, or Gemini endpoints, make sure your instrumentation captures that client call path.
