Skip to Content

How do I see errors and exceptions for calls to the Anthropic API?

Rius records a failed Anthropic call as an error on the span for that call, with the error class in error.type, and shows the exception and traceback in the trace. Once the Anthropic integration is on, every messages.create call gets its own span without changes to your call sites. Wrap the surrounding function in observe and the failed call appears inside your agent’s run, where the trace list marks the run as failed.

How it works

What the integration records. Each messages.create call becomes a span for that model call. It carries the model, input and output token usage including cache reads and writes, and the request and response messages. When the call fails, error.type holds the error class, such as anthropic.NotFoundError. Cost is computed by Rius from the model and tokens, so you send nothing for it. Prompt and response content follows your privacy controls. With content capture off, the ERROR status and exception.type remain, but the exception message, traceback and status description are stripped.

What needs your own span. The integration covers the model call only. It does not know your agent’s structure. Wrapping your function in observe makes a parent span named after that function, so the Anthropic call shows nested inside the run it belongs to. That parent also becomes the root, which matters for how Rius judges the run.

Where it shows. Trace status is derived from the spans, not reported by your code. A trace is failed when at least one span carries an OpenTelemetry ERROR status, normally a recorded exception. In the waterfall view, failed spans are highlighted along the path from the root to the error. Select the error span and its detail panel leads with the exception and traceback.

Caught and retried errors. If your code catches the Anthropic error, retries or falls back, and the root span finishes without an error of its own, the trace is still failed but carries a recovered badge. The errors stay counted. Only the verdict changes.

Set it up

  1. Install the instrumentation next to the library you already use. In Python the extra installs the instrumentation, not anthropic itself. Without anthropic in the environment, init() logs a DependencyConflict and the integration stays off. In TypeScript, install @arizeai/openinference-instrumentation-anthropic at version 0.2.7 or newer, and require @anthropic-ai/sdk before init() in CommonJS apps. The Anthropic integration page has the full setup.
pip install "glassflow-rius[anthropic]" anthropic
  1. Initialize Rius and wrap the function that makes the call in observe, so the failed call sits inside your agent’s run.
import anthropic import rius rius.init(api_key="ri_...", service_name="my-agent") claude = anthropic.Anthropic() # reads ANTHROPIC_API_KEY @rius.observe def handle(query: str) -> str: response = claude.messages.create( model="claude-haiku-4-5-20251001", max_tokens=200, messages=[{"role": "user", "content": query}], ) return response.content[0].text handle("What should I check when a collector drops spans?")
  1. Run a call that fails, for example with a model name that does not exist.
  2. Open Traces in the console and set the status filter to failed. Open the trace and follow the highlighted path from the root to the failed span.
  3. Read the detail panel for the exception and traceback, and the Raw tab for error.type. For more on reading a trace, see Exploring traces.

What you get

  • The error class on every failed call. error.type names the class, such as anthropic.NotFoundError, so you can tell a bad model name from other failures.
  • Exception and traceback in the span panel. The error span’s detail leads with them.
  • A trace verdict you do not compute. failed, completed or recovered, derived from the spans.
  • A list of failing model calls across runs. On the Spans tab, use the All kinds menu to pick LLM and filter by status to see only failed model calls. The search box matches span names, span IDs, trace IDs and session IDs.
  • Fast stepping. In a trace or on the Spans tab, ]e and [e jump to the next or previous failed span.
  • Retries as one event. Back-to-back calls of the same step with the same input collapse into one row such as 3 attempts · recovered when every attempt but the last failed.
  • Sharing a failure. Share on the trace list creates a read-only link to a frozen, filtered list. It carries summary tiles and trace metadata only, never span content.

For the wider picture, see Monitor AI agents in production.

When something else fits

  • If an Anthropic call produces no span at all, check that anthropic is installed next to the extra, since init() otherwise logs a DependencyConflict and leaves the integration off.
  • For calls through other client libraries, frameworks or protocols, start from the Integrations overview and use that integration’s page.
  • Time to first token is not recorded for auto-instrumented Anthropic streams, though token usage is.

Still stuck? Get help

Last updated on