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
| Call | Span kind | Auto-extracted |
|---|---|---|
client.chat.completions.create | llm | model, input/output tokens, temperature, messages, completion |
client.responses.create | llm | model, tokens, input, output text |
client.embeddings.create | llm | model, input tokens, input text |
Streaming (stream: true) | llm | everything 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-openaipip install openai opentelemetry-instrumentation-openaiMinimal 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)