Claude API monitoring for applications built on Anthropic models
by Obseria · AI and LLMs- OpenTelemetry
- AI Observability
- AI and LLMs
- Category
- AI and LLMs
- Key metrics
- 9
- Ready-made
- 5 dashboards & alerts
- Setup
- 3 steps
- Standard
- OTLP
Instrument the Anthropic SDK with OpenTelemetry and Obseria records every Messages call with model, input and output tokens, tool use and latency, inside the trace of the request that made it.
Messages and tool use traced
Each messages.create call becomes a span, and tool use turns are visible, so multi-step Claude workflows can be followed end to end.
Tokens, cache and cost
Input and output tokens per model and service, plus prompt cache usage where the instrumentation reports it, show what drives spend.
Errors before users notice
Rate limits, overloaded responses and timeouts are counted per model, with alerts on error rate and latency.
Obseria interface



Ready the moment data arrives
- Claude models: calls, error rate and p95 latency
- Input and output tokens per service and model
- Alert on rate-limit and overloaded errors
- Alert on token usage anomalies per feature
- Slowest Claude calls with their parent requests
Claude API features Obseria monitors
Messages API
Every call records requested model, stop reason, input and output tokens and duration.
Tool use
Tool use requests and the follow-up calls with tool results appear as steps of one trace.
Streaming
Streamed responses are measured until the final event, so the duration reflects what users wait for.
Prompt caching
Where the instrumentation reports cache reads and writes, you see how much context is served from the cache.
Python and TypeScript SDKs
Instrumentation exists for the official anthropic package and @anthropic-ai/sdk.
Claude on Amazon Bedrock
Calls through Bedrock are covered by the Bedrock instrumentation and appear with the full model ID.
The Anthropic Claude API signals that matter
Obseria collects these values automatically and shows them in ready-made dashboards and alerts.
| Metric | Unit | What it tells you |
|---|---|---|
gen_ai.client.operation.duration | s | Duration of Claude calls per model, the main latency signal for user-facing features. |
gen_ai.client.token.usage | {token} | Tokens per call, split into input and output via gen_ai.token.type. |
gen_ai.system | Span attribute that identifies the provider, anthropic for calls through the Anthropic SDK. | |
gen_ai.request.model | Span attribute with the requested Claude model; Obseria groups calls, errors and latency by it. | |
gen_ai.response.model | Span attribute with the model that answered, to confirm which version served production traffic. | |
gen_ai.usage.input_tokens | {token} | Prompt tokens of one call, including system prompt, history and documents. |
gen_ai.usage.output_tokens | {token} | Generated tokens of one call, the main driver of response time. |
gen_ai.request.max_tokens | {token} | Requested output limit; compare it with output tokens to find truncated answers. |
error.type | Error class of failed calls, for example rate limits, overloaded responses or timeouts. |
Set up Anthropic Claude API monitoring in minutes
- 1
Install the instrumentation
Add traceloop-sdk and opentelemetry-instrumentation-anthropic with pip, or @traceloop/node-server-sdk with npm for TypeScript.
- 2
Point the exporter at Obseria
Set TRACELOOP_BASE_URL and TRACELOOP_HEADERS to your Obseria OTLP endpoint and token; add TRACELOOP_TRACE_CONTENT=false to keep prompt content local.
- 3
Initialize before the first call
Call Traceloop.init before the Anthropic client is imported, send one message and check Model Performance in Obseria.
# pip install anthropic traceloop-sdk opentelemetry-instrumentation-anthropic
#
# Environment (set in your deployment):
# TRACELOOP_BASE_URL=${OBSERIA_OTLP_ENDPOINT}
# TRACELOOP_HEADERS=Authorization=Bearer%20${OBSERIA_TOKEN}
# TRACELOOP_TRACE_CONTENT=false # keep prompts and responses out of spans
# OTEL_SERVICE_NAME=contract-review
from traceloop.sdk import Traceloop
# Initialize before the Anthropic client is imported and used.
Traceloop.init(app_name="contract-review", disable_batch=False)
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY
message = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "List the termination clauses."}],
)
# Span attributes: gen_ai.system="anthropic", gen_ai.request.model,
# gen_ai.usage.input_tokens, gen_ai.usage.output_tokensWhy Claude API monitoring matters
Claude models power assistants, document analysis, code review tools and agents that call tools on their own. In production these features depend on a remote API with its own latency, rate limits and token-based billing. A long contract can push input tokens up, a tool use loop can turn one user request into many model calls, and a new prompt can change answer length and response time without a single error. Claude API monitoring makes these effects visible before they reach users or the budget.
With OpenTelemetry, every call through the Anthropic SDK becomes a span that follows the semantic conventions for generative AI: provider, model, token counts, stop reason and errors. Because the span sits inside the trace of the user request, you see how much of the total response time is spent waiting for Claude and how much in retrieval, databases or your own code.
Signals that matter for Anthropic API monitoring
- Latency per model:
gen_ai.client.operation.durationgrouped bygen_ai.request.model. Larger models answer more slowly, so compare features by the model they use. - Input tokens:
gen_ai.usage.input_tokensshows how much context each call sends. Long system prompts, chat history and attached documents add up quickly. - Output tokens:
gen_ai.usage.output_tokensexplains response time and, compared withgen_ai.request.max_tokens, reveals answers that were cut off. - Prompt caching: if you use prompt caching, check how much input is read from the cache. The Obseria setup guide captures cache hits per request where the instrumentation reports them.
- Errors:
error.typeseparates rate limits, overloaded responses, timeouts and invalid requests, because each needs a different fix.
Common Claude API problems and how to detect them
Rate limits and overload
Anthropic applies rate limits per organization and model, and busy periods can return overloaded errors. The SDK retries some failures automatically, which hides them from your code but not from latency. Error rate per model and repeated spans for one request reveal both.
Tool use loops
Agents built on tool use call Claude again after each tool result. A tool that keeps failing or returns unhelpful data can trigger many rounds. In the trace this is a long sequence of model and tool spans, and token usage per request rises sharply.
Context that keeps growing
Chat applications often resend the full history. Input tokens per conversation that grow with every turn are the signal to summarize, trim or cache stable context.
Model changes
Switching to a newer Claude model changes latency, output length and cost. Comparing calls, duration and tokens per model and per service.version after the switch shows the real effect in production.
Privacy: what leaves your application
Prompts and responses can contain personal data, contracts or source code. OpenLLMetry records message content on spans by default; set TRACELOOP_TRACE_CONTENT=false to send only metadata such as model, tokens and duration. If you decide to store content for debugging or evaluations, Obseria can keep it in full, masked or only as a hash, detects and masks personal data and keeps data in the EU. Your Anthropic API key stays in your application; Obseria never sees it.
Best practices for Claude monitoring
- Initialize the instrumentation before importing the Anthropic client.
- Set
service.name,service.versionanddeployment.environment.namefor every service that calls Claude. - Use dated model identifiers in production so you know exactly which model served a request.
- Add attributes for feature and tenant to attribute token usage and cost.
- Alert on error rate and p95 per model, and on unusual token growth per feature.
How Obseria helps with Claude API monitoring
Obseria receives Claude spans over OTLP and shows them in the full trace together with HTTP, database and queue spans. Model Performance compares Claude models by calls, error rate, weighted p95 and tokens. AI Observability adds token cost per model, feature and tenant, budgets and anomaly alerts, agent workflows as a graph and guardrails and evaluations for response quality. When a Claude feature slows down, Obseria Intelligence correlates rate limits, retries, prompt growth and deployments and presents the root cause with its chain of evidence. Obseria is an independent product and is not affiliated with Anthropic.
Learn more
What is LLM observability?
What is LLM observability? How to trace LLM apps, RAG and AI agents, which metrics matter (tokens, cost, latency, quality) and OTel GenAI conventions.
What is OpenTelemetry?
What is OpenTelemetry? Learn how OTel's APIs, SDKs, Collector, OTLP and semantic conventions produce vendor-neutral traces, metrics, logs and profiles.
Anthropic Claude API monitoring FAQ
The setup guide uses OpenLLMetry: traceloop-sdk with opentelemetry-instrumentation-anthropic for Python, or @traceloop/node-server-sdk for TypeScript. The spans follow the OpenTelemetry GenAI semantic conventions.
Only if you want that. Set TRACELOOP_TRACE_CONTENT=false to send metadata only. Stored content can be masked or hashed in Obseria, and personal data is detected and masked.
Yes. Each model call and each tool use turn is part of the same trace, and Obseria visualizes multi-step agent workflows as a graph.
Calls through Bedrock are traced with the Bedrock instrumentation. Claude Code exports its own telemetry; see the Claude Code integration.
The instrumentation records attributes around the existing call and exports spans in batches in the background. The model call itself takes far longer than the recording.
Start monitoring Anthropic Claude API today
Connect Anthropic Claude API in minutes with OpenTelemetry or the Obseria Agent. Free for 14 days.