> ## 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

> TokenLabのOpenAI互換リクエストをLangfuseでトレースする

## 概要

Langfuseは、OpenAI SDKがTokenLabの `/v1` ベースURLで設定されている場合、そのOpenAI統合を通じてTokenLabの呼び出しをトレースできます。

<Note>
  **タイプ**: 可観測性 (Observability)

  **主要パス**: OpenAI SDKトレース

  **サポート信頼度**: サポートされているOpenAI互換トレースパス
</Note>

## 環境変数

```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"
```

## 例

```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
```

## エンドポイントに関する注意点

このページでは、OpenAI SDKパスを使用したLangfuseのトレースについて説明しています。アプリケーションでTokenLabネイティブのResponses、Anthropic Messages、またはGeminiエンドポイントを使用している場合は、そのクライアント呼び出しパスがインストゥルメンテーションによってキャプチャされていることを確認してください。
