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

# Opik

> Trace TokenLab OpenAI-compatible requests with Opik

## Overview

Opik can log TokenLab calls by wrapping an OpenAI client that points to TokenLab's OpenAI-compatible endpoint.

<Note>
  **Type**: Observability

  **Primary Path**: OpenAI SDK tracing wrapper

  **Support Confidence**: Supported OpenAI-compatible tracing path
</Note>

## Installation

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

## Environment

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

## Wrap the OpenAI Client

```python theme={null}
import os

from openai import OpenAI
from opik.integrations.openai import track_openai

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

openai_client = track_openai(client)
```

## Log a Chat Completion

```python theme={null}
completion = openai_client.chat.completions.create(
    model="claude-sonnet-5",
    messages=[
        {"role": "user", "content": "Summarize why LLM observability matters."}
    ],
)

print(completion.choices[0].message.content)
```

## Endpoint Notes

This setup traces the OpenAI-compatible SDK path. If you use TokenLab native endpoints outside the OpenAI SDK, instrument that client or workflow separately.
