> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aiagentshouse.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start

> Get started with the AI Agents House SDK in under 5 minutes

This guide will help you set up the AI Agents House SDK and start monitoring your AI agents quickly.

## Prerequisites

* Node.js version 18 or higher
* An AI Agents House API key and organization ID
* An existing AI agent using Anthropic or OpenAI

## Installation

Install the SDK using your preferred package manager:

<Tabs>
  <Tab title="npm">
    ```bash theme={null}
    npm install @agent-governance/node
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={null}
    pnpm add @agent-governance/node
    ```
  </Tab>

  <Tab title="bun">
    ```bash theme={null}
    bun add @agent-governance/node
    ```
  </Tab>

  <Tab title="deno">
    ```bash theme={null}
    deno install npm:@agent-governance/node
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={null}
    yarn add @agent-governance/node
    ```
  </Tab>
</Tabs>

## Basic Setup

### 1. Initialize the Monitor

Create a new `AgentMonitor` instance with your configuration:

```javascript theme={null}
import { AgentMonitor } from '@agent-governance/node';

const monitor = new AgentMonitor({
  apiKey: process.env.AGENT_GOVERNANCE_API_KEY,
  organizationId: process.env.AGENT_GOVERNANCE_ORG_ID,
  environment: 'development',
  enableComplianceChecks: true,
  enableLogging: true
});
```

<Note>
  Store your API credentials in environment variables for security. Never commit API keys to version control.
</Note>

### 2. Register Your Agent

Before tracking interactions, register your agent with the monitoring system:

```javascript theme={null}
await monitor.registerAgent({
  id: 'customer-service-agent',
  name: 'Customer Service Assistant',
  category: 'tool_calling',
  specialty: 'customer_service',
  version: '1.0.0',
  llmProvider: 'anthropic',
  model: 'claude-3-5-sonnet-20241022',
  description: 'AI assistant for customer service inquiries',
  complianceSettings: {
    sr11_7_enabled: true,
    fair_lending_monitoring: true,
    bsa_aml_checks: true
  }
});
```

### 3. Track Interactions

Start monitoring your agent's conversations:

```javascript theme={null}
const sessionId = 'session-' + Date.now();
const agentId = 'customer-service-agent';

// Start a new conversation
monitor.trackConversationStart(agentId, sessionId);

// Track user message
monitor.trackUserMessage(agentId, sessionId, 'What is my account balance?');

// Track agent response
monitor.trackAgentResponse(agentId, sessionId, 'I can help you check your account balance. Let me retrieve that information.');

// Track tool usage (if applicable)
monitor.trackToolCall(
  agentId,
  sessionId,
  'get_account_balance',
  { accountId: 'user123' },
  { balance: 1250.50, currency: 'USD' },
  150 // execution time in ms
);

// Clean shutdown when done
await monitor.shutdown();
```

## LLM Integration Setup

For automatic monitoring without manual tracking, wrap your existing LLM clients:

### Anthropic Integration

```javascript theme={null}
import { AnthropicAgentMonitor } from '@agent-governance/node';
import Anthropic from '@anthropic-ai/sdk';

// Initialize the monitor
const monitor = new AnthropicAgentMonitor({
  apiKey: process.env.AGENT_GOVERNANCE_API_KEY,
  organizationId: process.env.AGENT_GOVERNANCE_ORG_ID
});

// Register your agent
await monitor.registerAgent({
  id: 'banking-assistant',
  name: 'Banking Assistant',
  category: 'tool_calling',
  version: '1.0.0',
  llmProvider: 'anthropic',
  model: 'claude-3-5-sonnet-20241022'
});

// Wrap the Anthropic client
const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
const monitoredAnthropic = monitor.wrapAnthropic(anthropic, 'banking-assistant');

// Use normally - all interactions are automatically tracked
const response = await monitoredAnthropic.messages.create({
  model: 'claude-3-5-sonnet-20241022',
  messages: [{ role: 'user', content: 'Help me with my account' }],
  sessionId: 'session-123' // Optional: link events to a session
});
```

### OpenAI Integration

```javascript theme={null}
import { OpenAIAgentMonitor } from '@agent-governance/node';
import OpenAI from 'openai';

const monitor = new OpenAIAgentMonitor({
  apiKey: process.env.AGENT_GOVERNANCE_API_KEY,
  organizationId: process.env.AGENT_GOVERNANCE_ORG_ID
});

await monitor.registerAgent({
  id: 'gpt-assistant',
  name: 'GPT Assistant',
  category: 'persona',
  version: '1.0.0',
  llmProvider: 'openai',
  model: 'gpt-4'
});

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const monitoredOpenAI = monitor.wrapOpenAI(openai, 'gpt-assistant');

const response = await monitoredOpenAI.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello!' }]
});
```

## Configuration Options

Customize the monitoring behavior with these configuration options:

```javascript theme={null}
const monitor = new AgentMonitor({
  apiKey: 'your-api-key',
  organizationId: 'your-org-id',

  // Optional configurations
  endpoint: 'https://api.aiagentshouse.com', // Custom endpoint
  environment: 'production', // 'development', 'staging', or 'production'
  batchSize: 100, // Events per batch (1-1000)
  flushInterval: 5000, // Milliseconds between flushes (min 100)
  enableComplianceChecks: true, // Enable real-time compliance monitoring
  enableLogging: true, // Enable SDK logging
  logLevel: 'info', // 'debug', 'info', 'warn', or 'error'
  retryAttempts: 3, // Number of retry attempts for failed requests
  retryDelay: 1000 // Delay between retries in milliseconds
});
```

## Compliance Monitoring

When `enableComplianceChecks` is enabled, the SDK automatically scans interactions for:

* **PII Detection**: Emails, phone numbers, SSNs, and other sensitive data
* **Fair Lending**: Discriminatory language and bias indicators
* **BSA/AML**: Suspicious activity keywords and patterns

Compliance violations are automatically flagged and included in your event data for review.

## Complete Example

Here's a complete working example that demonstrates all key features:

<CodeGroup>
  ```javascript Basic Example theme={null}
  import { AgentMonitor } from '@agent-governance/node';

  async function basicExample() {
    const monitor = new AgentMonitor({
    apiKey: process.env.AGENT_GOVERNANCE_API_KEY,
    organizationId: process.env.AGENT_GOVERNANCE_ORG_ID,
    environment: 'development',
    enableComplianceChecks: true
  });

  // Register agent
  await monitor.registerAgent({
    id: 'support-agent',
    name: 'Support Agent',
    category: 'persona',
    version: '1.0.0',
    llmProvider: 'anthropic',
    model: 'claude-3-5-sonnet-20241022',
    description: 'Customer support assistant'
  });

  // Track conversation
  const sessionId = 'session-' + Date.now();
  monitor.trackConversationStart('support-agent', sessionId);
  monitor.trackUserMessage('support-agent', sessionId, 'I need help with my account');
  monitor.trackAgentResponse('support-agent', sessionId, 'I\'d be happy to help with your account. What specific assistance do you need?');

  // Flush events and shutdown
  await monitor.flush();
  await monitor.shutdown();
  }

  basicExample().catch(console.error);
  ```

  ```javascript Anthropic Integration theme={null}
  import { AnthropicAgentMonitor } from '@agent-governance/node';
  import Anthropic from '@anthropic-ai/sdk';

  async function anthropicExample() {
    const monitor = new AnthropicAgentMonitor({
      apiKey: process.env.AGENT_GOVERNANCE_API_KEY,
      organizationId: process.env.AGENT_GOVERNANCE_ORG_ID
    });

    await monitor.registerAgent({
      id: 'claude-agent',
      name: 'Claude Banking Assistant',
      category: 'tool_calling',
      specialty: 'personal_banking',
      version: '1.0.0',
      llmProvider: 'anthropic',
      model: 'claude-3-5-sonnet-20241022'
    });

    const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
    const monitoredAnthropic = monitor.wrapAnthropic(anthropic, 'claude-agent');

    const response = await monitoredAnthropic.messages.create({
      model: 'claude-3-5-sonnet-20241022',
      messages: [{ role: 'user', content: 'What services do you offer?' }],
      sessionId: 'banking-session-123'
    });

    console.log(response.content[0].text);
    await monitor.shutdown();
  }

  anthropicExample().catch(console.error);
  ```
</CodeGroup>

## Next Steps

Now that you have the basics working:

<CardGroup cols={2}>
  <Card title="Compliance Engine" icon="shield-check" href="/features/compliance-engine">
    Learn about built-in compliance monitoring
  </Card>

  <Card title="Manual Tracking" icon="hand" href="/features/manual-tracking">
    Detailed event tracking capabilities
  </Card>

  <Card title="Configuration" icon="gear" href="/features/configuration">
    Advanced configuration options
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/overview">
    Complete API documentation
  </Card>
</CardGroup>

<Tip>
  Check out the [examples](https://github.com/your-repo/examples) folder in the SDK repository for more detailed use cases and integration patterns.
</Tip>
