Skip to main content
The Anthropic integration provides automatic monitoring for Claude API calls with minimal code changes. Simply wrap your existing Anthropic client to start tracking all interactions, token usage, costs, and compliance violations.

Prerequisites

  • @anthropic-ai/sdk package installed
  • AI Agents House SDK installed
  • Valid Anthropic and AI Agents House API keys

Basic Setup

Installation

If you haven’t already, install both the Anthropic SDK and AI Agents House SDK:

Initialize the Monitor

Use the AnthropicAgentMonitor class for automatic Claude monitoring:

Register Your Agent

Register your Claude-powered agent with the monitoring system:

Wrap the Anthropic Client

Wrap your existing Anthropic client to enable automatic monitoring:

Usage Examples

Basic Conversation

With Tool Calls

The integration automatically tracks when Claude decides to call tools:

Multi-turn Conversations

For conversations with multiple exchanges, including tool results:

Automatic Tracking Features

The Anthropic integration automatically captures:

Conversation Events

  • Conversation Start: When a new session begins
  • User Messages: All user inputs including text and tool results
  • Agent Responses: Claude’s text responses
  • Tool Calls: When Claude decides to use a tool

Performance Metrics

  • Latency: Time taken for each API call
  • Token Usage: Input, output, and total tokens
  • Cost Calculation: Automatic cost tracking based on model pricing
  • Response Quality: Optional quality scoring

Compliance Monitoring

  • PII Detection: Scans for personal information in responses
  • Fair Lending: Checks for discriminatory language
  • BSA/AML: Monitors for suspicious activity indicators

Configuration Options

Session Management

Link related interactions by providing a sessionId:

Monitoring Options

Pass additional monitoring configuration:

Custom User Identification

Track which customer is interacting with the agent:

Cost Tracking

The integration automatically calculates costs based on Claude’s pricing:
  • Input: $3 per million tokens
  • Output: $15 per million tokens
Costs are automatically calculated and included in the tracked events:

Error Handling

The wrapper preserves normal error handling while tracking errors:

Banking Example

Here’s a complete example for a banking use case:

Best Practices

Troubleshooting

Ensure you’ve properly configured your API key and organization ID. Check that monitor.flush() is called if you’re not seeing events immediately.
Verify you’re using the correct model name. Cost calculations are based on the model specified in your API call.
Make sure enableComplianceChecks: true is set in your monitor configuration. Compliance checks only run on agent responses.
Tool calls are automatically detected when Claude returns tool_use content. Ensure your tools are properly configured in your Claude API call.

Next Steps

OpenAI Integration

Learn about monitoring GPT models

Manual Tracking

Advanced event tracking capabilities

Compliance Engine

Deep dive into compliance monitoring

Configuration

Advanced configuration options