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

# Why Monitoring & Firewall?

> Protect your AI applications in production — real-time monitoring of agent behavior and automated blocking of harmful content.

AI applications in production face two critical risks:

1. **Unpredictable agent behavior** — AI agents can hallucinate, leak sensitive data, call unauthorized tools, or drift from their intended goals
2. **Harmful content generation** — Models can produce toxic, biased, or policy-violating outputs that reach your end users

Know Your AI's **Monitoring** and **Firewall** work together to address both:

<CardGroup cols={2}>
  <Card title="Monitoring" icon="chart-line">
    **See everything.** Track every AI request, response, tool call, token, cost, and error in real time. Trace multi-step agent workflows as span trees. Catch anomalies before they become incidents.
  </Card>

  <Card title="Firewall" icon="shield">
    **Block threats.** Validate every input and output against content safety policies. Block jailbreak attempts, prompt injection, PII leakage, and harmful content — before they reach your users.
  </Card>
</CardGroup>

## Architecture

```
User Input
    │
    ▼
┌─────────────────────────┐
│   Firewall (Input)      │  ← Block jailbreaks, prompt injection, PII
│   beforeRequest hook    │
└────────────┬────────────┘
             │  ✔ Safe
             ▼
┌─────────────────────────┐
│   AI Model              │  ← Your LLM (Gemini, GPT, Claude, etc.)
│                         │
└────────────┬────────────┘
             │
             ▼
┌─────────────────────────┐
│   Firewall (Output)     │  ← Flag harmful, biased, or toxic responses
│   afterResponse hook    │
└────────────┬────────────┘
             │  ✔ Safe
             ▼
┌─────────────────────────┐
│   Monitoring            │  ← Capture tokens, cost, latency, traces
│   Know Your AI Backend  │
└─────────────────────────┘
             │
             ▼
        User Response
```

## What you can protect against

| Threat                  | Monitoring detects                       | Firewall blocks                |
| ----------------------- | ---------------------------------------- | ------------------------------ |
| **Jailbreak attempts**  | Logs the input for review                | Blocks before reaching model   |
| **Prompt injection**    | Tracks anomalous inputs                  | Blocks injected instructions   |
| **PII leakage**         | Flags responses containing personal data | Blocks PII from being returned |
| **Harmful content**     | Captures and categorizes output          | Blocks toxic/hateful responses |
| **Excessive agency**    | Traces all tool calls and agent steps    | —                              |
| **Cost spikes**         | Alerts on abnormal token usage           | —                              |
| **Latency degradation** | Tracks TTFB and response times           | —                              |
| **Model errors**        | Captures error types and rates           | —                              |

## Getting started

<Steps>
  <Step title="Install the SDK">
    ```bash theme={null}
    npm install @know-your-ai/node @know-your-ai/firewall
    ```
  </Step>

  <Step title="Get your DSN and Firewall API key">
    From the [Know Your AI dashboard](https://knowyourai.hydrox.ai):

    * **DSN**: Settings → API Keys
    * **Firewall API key**: Product → Firewall → Generate Key
  </Step>

  <Step title="Initialize with both integrations">
    ```typescript theme={null}
    import * as KnowYourAI from '@know-your-ai/node';
    import { firewallIntegration } from '@know-your-ai/firewall';

    KnowYourAI.init({
      dsn: process.env.KNOW_YOUR_AI_DSN!,
      integrations: [
        KnowYourAI.googleGenAIIntegration(),
        firewallIntegration({
          baseUrl: process.env.FIREWALL_URL!,
          apiKey: process.env.FIREWALL_API_KEY!,
          onInputViolation: 'block',
          onOutputViolation: 'log',
        }),
      ],
    });
    ```
  </Step>

  <Step title="View dashboards">
    Open the **Monitoring** and **Firewall Logs** pages in your product dashboard to see real-time data.
  </Step>
</Steps>

## Next steps

<CardGroup cols={2}>
  <Card title="Real-time monitoring" icon="radar" href="/monitoring-firewall/realtime-monitoring">
    Set up production monitoring with dashboards, tracing, and alerts.
  </Card>

  <Card title="Content firewall" icon="shield-halved" href="/monitoring-firewall/content-firewall">
    Configure input/output validation and block harmful content.
  </Card>

  <Card title="Agent safety" icon="robot" href="/monitoring-firewall/agent-safety">
    Monitor and protect multi-step AI agent workflows.
  </Card>

  <Card title="Production recipes" icon="book" href="/monitoring-firewall/recipes">
    Copy-paste recipes for common production setups.
  </Card>
</CardGroup>
