Skip to main content
Automatically capture all OpenAI Chat Completions and Responses API calls.

Setup

import traceroot
from traceroot import Integration

traceroot.initialize(integrations=[Integration.OPENAI])

Usage

Once initialized, all OpenAI calls are captured automatically:
import openai

client = openai.OpenAI()

# This call is automatically traced
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of France?"},
    ],
)

print(response.choices[0].message.content)

What Gets Captured

AttributeDescription
Modelgpt-4o, gpt-4o-mini, o3, etc.
MessagesInput messages array
ResponseCompletion content
TokensPrompt, completion, and total tokens
CostCalculated from token usage and model pricing
LatencyRequest duration