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

# Install it yourself

> Add the agent-traffic package to your code by hand.

Prefer to wire it in yourself? Install the package directly. To have your agent do this instead, see the [Quickstart](https://agent-traffic.mintlify.site/quickstart.md).

**1. Install the package**

```bash theme={null}
npm i @mintlify/agent-traffic
```

It has no dependencies and runs anywhere `fetch` does: Node 20.10+, Bun, Deno, Cloudflare Workers and Vercel Edge.

**2. Classify a user agent**

```js theme={null}
import { classify } from '@mintlify/agent-traffic'

classify({ userAgent: 'axios/1.13.2' })
// { category: 'bot', kind: 'http-client', name: 'axios', verified: null, confidence: 'medium',
//   reasons: ['user agent is axios'] }
```

The user agent alone is enough for logs and quick checks.

**3. Classify a full request**

Pass the request headers and the real client IP to unlock header checks and verification:

```js theme={null}
import { classify, loadIpRanges } from '@mintlify/agent-traffic'

const ipRanges = await loadIpRanges()

const result = classify(
  { headers: request.headers, ip: request.headers.get('cf-connecting-ip') },
  { ipRanges }
)
```

A spoofed crawler now comes back as an impersonator:

```js theme={null}
// { category: 'bot', kind: 'impersonator', verified: false, confidence: 'high',
//   reasons: ["claims to be GPTBot but 73.12.4.9 is outside OpenAI's published ranges"] }
```

**4. Act on the category**

```js theme={null}
if (result.category === 'agent') {
  // serve markdown, log it, meter it
}
```

See [Categories](https://agent-traffic.mintlify.site/concepts/categories.md) for what each value means.

> [!NOTE]
>
> On Cloudflare Workers, load IP ranges inside the request handler rather than at the top of the module. Workers don't allow `fetch` at global scope. See [Request-time classification](https://agent-traffic.mintlify.site/guides/request-time.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.