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

# OpenLLMetry

> Theo dõi các yêu cầu tương thích với OpenAI của TokenLab bằng OpenLLMetry

## Tổng quan

Công cụ đo lường (instrumentation) OpenAI của OpenLLMetry theo dõi các lệnh gọi được thực hiện thông qua SDK OpenAI chính thức. Hãy cấu hình SDK đó với URL cơ sở `/v1` của TokenLab.

<Note>
  **Loại**: Khả năng quan sát (Observability)

  **Đường dẫn chính**: Đo lường SDK OpenAI

  **Độ tin cậy hỗ trợ**: Đường dẫn quan sát tương thích với OpenAI được hỗ trợ
</Note>

## Cài đặt

```bash theme={null}
pip install opentelemetry-instrumentation-openai openai
```

## Môi trường

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

## Ví dụ

```python theme={null}
import os

from openai import OpenAI
from opentelemetry.instrumentation.openai import OpenAIInstrumentor

OpenAIInstrumentor().instrument()

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

client.chat.completions.create(
    model="claude-sonnet-5",
    messages=[{"role": "user", "content": "Trace this request"}],
)
```

## Lưu ý về Endpoint

Sử dụng đường dẫn này cho các lệnh gọi TokenLab tương thích với SDK OpenAI. Đối với các endpoint gốc của TokenLab, hãy đo lường HTTP hoặc SDK client thực sự gửi các yêu cầu đó.
