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

# Langfuse

> Trace AI Sonar OpenAI-compatible requests with Langfuse

## Overview

Langfuse can trace AI Sonar calls through its OpenAI integration when the OpenAI SDK is configured with AI Sonar'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 API_KEY="sk-your-api-key"
```

## Example

```python theme={null}
import os

from langfuse import observe
from langfuse.openai import openai

openai.api_key = os.environ["API_KEY"]
openai.base_url = "https://api.aisonar.dev/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 AI Sonar native Responses, Anthropic Messages, or Gemini endpoints, make sure your instrumentation captures that client call path.
