OpenAI

chat.completions, responses, and embeddings auto-capture as kind='llm' spans, including streaming.

Install the instrumentor alongside the openai SDK and every call inside wrap your agent becomes a span with model, tokens, temperature, prompt, and completion. The provider field is openai.

What's captured

CallSpan kindAuto-extracted
client.chat.completions.createllmmodel, input/output tokens, temperature, messages, completion
client.responses.createllmmodel, tokens, input, output text
client.embeddings.createllmmodel, input tokens, input text
Streaming (stream: true)llmeverything above, tokens from the final chunk.usage

Azure OpenAI and OpenAI-compatible endpoints (Together, Groq) fire the same instrumentation and report provider='openai'.

Install

npm install openai @opentelemetry/instrumentation-openai
pip install openai opentelemetry-instrumentation-openai

Minimal example

import trodo from 'trodo-node';
import OpenAI from 'openai';

trodo.init({ siteId: process.env.TRODO_SITE_ID });
const openai = new OpenAI();

await trodo.wrapAgent('faq-bot', async (run) => {
  const r = await openai.chat.completions.create({
    model: 'gpt-4o-mini',
    messages: [{ role: 'user', content: 'What is HNSW?' }],
  });
  run.setOutput(r.choices[0].message.content); // one kind='llm' span, no extra code
});
import os, trodo
from openai import OpenAI

trodo.init(site_id=os.environ['TRODO_SITE_ID'])
client = OpenAI()

with trodo.wrap_agent('faq-bot') as run:
    r = client.chat.completions.create(
        model='gpt-4o-mini',
        messages=[{'role': 'user', 'content': 'What is HNSW?'}],
    )
    run.set_output(r.choices[0].message.content)

On this page