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

# OpenLIT

> 使用 OpenLIT 監控 TokenLab OpenAI 相容請求

## 概覽

OpenLIT 對官方 OpenAI SDK 進行了檢測（instrumentation），因此可以透過將 SDK 客戶端配置為 TokenLab 的 `/v1` 基礎 URL 來監控 TokenLab 請求。

<Note>
  **類型**: 可觀測性 (Observability)

  **主要路徑**: OpenAI SDK 檢測

  **支援信心**: 支援的 OpenAI 相容可觀測性路徑
</Note>

## 安裝

```bash theme={null}
pip install openlit openai
```

## 環境變數

```bash theme={null}
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
```

## 範例

```python theme={null}
import os

import openlit
from openai import OpenAI

openlit.init()

client = OpenAI(
    api_key=os.environ["TOKENLAB_API_KEY"],
    base_url="https://api.tokenlab.sh/v1",
)

response = client.chat.completions.create(
    model="claude-sonnet-5",
    messages=[{"role": "user", "content": "Hello from OpenLIT"}],
)
```

## 端點注意事項

OpenLIT 遵循 SDK 檢測路徑。Chat Completions 是最安全的整合介面；其他 TokenLab 原生呼叫取決於您的 OpenLIT/OpenTelemetry 設定是否捕捉該 SDK 方法或 HTTP 客戶端。
