Anthropic
messages.create, including streaming and tool use, auto-captures as kind='llm' with full token extraction.
Install the instrumentor and every Claude call inside wrap your agent becomes a span. The provider field is anthropic.
What's captured
| Call | Span kind | Auto-extracted |
|---|---|---|
client.messages.create | llm | model, input/output tokens, stop_reason, messages, completion |
client.messages.stream | llm | same, accumulated across deltas |
client.messages.count_tokens | llm | model, input tokens |
Install
npm install @anthropic-ai/sdk @opentelemetry/instrumentation-anthropicpip install anthropic opentelemetry-instrumentation-anthropicMinimal example
import trodo from 'trodo-node';
import Anthropic from '@anthropic-ai/sdk';
trodo.init({ siteId: process.env.TRODO_SITE_ID });
const anthropic = new Anthropic();
await trodo.wrapAgent('summarizer', async (run) => {
const r = await anthropic.messages.create({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 1024,
messages: [{ role: 'user', content: `Summarize:\n${text}` }],
});
run.setOutput(r.content[0].type === 'text' ? r.content[0].text : '');
});import os, trodo, anthropic
trodo.init(site_id=os.environ['TRODO_SITE_ID'])
client = anthropic.Anthropic()
with trodo.wrap_agent('summarizer') as run:
r = client.messages.create(
model='claude-3-5-sonnet-20241022',
max_tokens=1024,
messages=[{'role': 'user', 'content': f'Summarize:\n{text}'}],
)
run.set_output(r.content[0].text)