Mirror of @voightxyz/openai@0.1.7 — same otel: true flag, same gen_ai.* + ai.* attribute shape, same voight.source: 'wrapper' dedup marker, same optional peer on @opentelemetry/api.
New option
import Anthropic from '@anthropic-ai/sdk'
import { wrapAnthropic } from '@voightxyz/anthropic'
const anthropic = wrapAnthropic(new Anthropic(), {
agent: 'production-chat-api',
otel: true, // ← new
})When otel: true, every captured messages.create event is also written as an OpenTelemetry span named voight.anthropic.messages with gen_ai.system: 'anthropic', model, token counts, finish reason, and the voight.source: 'wrapper' dedup marker.
What didn't change
- Default
otel: falseis byte-identical to 0.1.7. Existing users see no behaviour change. @opentelemetry/apiis an optional peer dep. Projects that never setotel: trueare unaffected.- When
otel: trueis set but the package isn't installed, the wrapper falls back to direct ingestion only.
Differences from the OpenAI port
- Span name is
voight.anthropic.messages(Anthropic exposes the Messages API, notchat.completions). gen_ai.systemresolves toanthropic.
Companion releases
Validation
Tests: 92 → 109 green (17 new). B.8.4: removing the voight.source stamp triggers 3 failures, matching the OpenAI port.
End-to-end smoke from the npm registry: real Anthropic call with otel: true + VoightExporter in the same OTel runtime → exactly 1 POST to /v1/events per call.
Install
npm install @voightxyz/anthropic @opentelemetry/api