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

# OpenLIT

> 使用 OpenLIT 监控 AI Sonar OpenAI 兼容请求

## 概述

OpenLIT 对官方 OpenAI SDK 进行了插桩，因此可以通过将 SDK 客户端配置为 AI Sonar 的 `/v1` 基础 URL 来监控 AI Sonar 请求。

<Note>
  **类型**: 可观测性

  **主要路径**: OpenAI SDK 插桩

  **支持置信度**: 支持的 OpenAI 兼容可观测性路径
</Note>

## 安装

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

## 环境

```bash theme={null}
export API_KEY="sk-your-api-key"
```

## 示例

```python theme={null}
import os

import openlit
from openai import OpenAI

openlit.init()

client = OpenAI(
    api_key=os.environ["API_KEY"],
    base_url="https://api.aisonar.dev/v1",
)

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

## 端点说明

OpenLIT 遵循 SDK 插桩路径。Chat Completions 是最安全的集成界面；其他 AI Sonar 原生调用取决于您的 OpenLIT/OpenTelemetry 设置是否捕获了该 SDK 方法或 HTTP 客户端。
