Frameworks & Platforms
Phoenix
Trace TokenLab OpenAI-compatible requests with Arize Phoenix
Overview
Phoenix can record calls from an OpenAI Python client whose Base URL points to TokenLab.
Installation
pip install arize-phoenix openinference-instrumentation-openai openaiEnvironment
export TOKENLAB_API_KEY="sk-your-tokenlab-key"Register Phoenix
Start Phoenix locally or use an existing deployment before running this example. By default, register() sends traces to the local OTLP/gRPC collector at http://localhost:4317. For another deployment, configure the collector endpoint and authentication using the Phoenix setup guide. Installing the SDK does not start the collector.
from phoenix.otel import register
tracer_provider = register(
project_name="tokenlab-app",
auto_instrument=True,
)Call TokenLab
import os
from openai import OpenAI
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": "Write a short haiku."}],
)
print(response.choices[0].message.content)Endpoint Notes
Phoenix traces the OpenAI SDK call path. Use this page for Chat Completions style TokenLab calls. Other TokenLab native endpoints can still be traced if your application instrumentation captures the client you use for those requests.