messages.create calls —
both sync and async. Every call is recorded as a span with model name,
token usage, cost, and full message content.
Install
valiqor plus anthropic>=0.18.0.
Zero-Config (Recommended)
Add a single import at the top of your app — all Anthropic calls are automatically traced:messages.create call is now traced with full metadata.
Selective Instrumentation
If you only want Anthropic tracing (not other providers), use the provider-specific function:Async Support
Async Anthropic calls are automatically traced:Content Block Handling
Anthropic responses use content blocks. Valiqor automatically extracts text from both string content and structured content block lists:What Gets Captured
Each traced Anthropic call records:| Field | Description |
|---|---|
model | Model name (e.g. claude-sonnet-4-20250514) |
input_tokens | Input token count |
output_tokens | Output token count |
total_tokens | Combined token count |
cost | Estimated cost in USD |
stop_reason | Why the model stopped (e.g. end_turn, max_tokens) |
messages | User and assistant messages |
duration_ms | Call latency |
status | Success or error |
With Workflows
Combine withtrace_workflow to group multiple Anthropic calls into a
single trace:
claude-assistant trace.
Disabling
To disable Anthropic tracing:Limitations
- Streaming is not currently instrumented — streamed responses are not captured in traces
- Tool use — Anthropic tool use responses are not explicitly parsed (tool_use content blocks are captured as raw content)