github.com/anthropics/anthropic-sdk-go). It wires a middleware that records request and response attributes for the Messages API (/v1/messages), both buffered and streamed, including the full token-usage breakdown (input, output, cache-read and cache-creation) and thinking content.
Installation
Usage
Set
LANGWATCH_API_KEY and ANTHROPIC_API_KEY environment variables before running.client.Messages.NewStreaming(...) and drain it; the span is recorded once the stream concludes.
The middleware captures input and output content by default (
langwatch.DataCaptureAll). Pass otelanthropic.WithDataCapture(langwatch.DataCaptureNone) to opt out. If your client points at an Anthropic-compatible gateway (e.g. AWS Bedrock or Google Vertex), set the provider with otelanthropic.WithGenAIProvider(...).Related
- Go Integration Guide - Setup, manual spans, data capture and the REST client
- Go SDK API Reference - Instrumentation options and collected attributes
- Capturing Evaluations & Guardrails - Log evaluations and implement guardrails in your Anthropic applications