Overview
OpenLLMetry’s OpenAI instrumentation traces calls made through the official OpenAI SDK. Configure that SDK with TokenLab’s /v1 base URL.
Type: ObservabilityPrimary Path: OpenAI SDK instrumentationSupport Confidence: Supported OpenAI-compatible observability path
Installation
pip install opentelemetry-instrumentation-openai openai
Environment
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
Example
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"}],
)
Endpoint Notes
Use this path for OpenAI SDK-compatible TokenLab calls. For TokenLab native endpoints, instrument the HTTP or SDK client that actually sends those requests.