SDK reference

AI traffic

Add one line to your server, and the AI traffic page shows which AI crawlers and agents read your pages.

proxy.ts
export { proxy } from "@databuddy/sdk/agents";

Visitors that AI assistants send you show up through the tracker on its own. Crawlers and coding agents such as GPTBot, ClaudeBot and Claude Code don't run JavaScript, so they appear only once @databuddy/sdk/agents runs on your server.

  1. Agent requests a page
  2. Your server reports it
  3. Databuddy checks the agent
  4. AI traffic page

Set it up on your host

No API key is needed, only your website ID in NEXT_PUBLIC_DATABUDDY_CLIENT_ID, its NUXT_PUBLIC_, VITE_ or REACT_APP_ versions, or DATABUDDY_WEBSITE_ID. Needs @databuddy/sdk 3.0.1 or later.

proxy.ts
export { proxy } from "@databuddy/sdk/agents";

On Next.js 15, name the file middleware.ts and export proxy as middleware. Fumadocs sites need nothing else.

If your proxy has a matcher, don't exclude .md and .txt paths. Those are the markdown pages and llms.txt files AI tools fetch most.

Requests count only when they come from your website's domain or an allowed origin, so local development never shows up.

Send Vercel logs instead

On Vercel Pro or Enterprise, add a drain under Team Settings → Drains with Logs, Custom Endpoint and this URL:

https://basket.databuddy.cc/vercel/your_website_id

Select the Static Files, Functions, Edge Functions and Rewrites sources and Production, choose JSON or NDJSON, and leave sampling off. Vercel bills drains by volume. Logs have no Accept header, so markdown is recognized from .md paths only, but they add the HTTP status each agent got.

Check what gets recorded

Deploy, open the AI traffic page and click Test setup. Databuddy requests your homepage and /llms.txt as GPTBot and tells you whether each was recorded; test requests never show in your data.

trackAgents reports GET and HEAD requests from known AI user agents, agent browsers that sign requests with Signature-Agent, and non-browser clients that prefer markdown. It skips images, scripts, styles and fonts, never throws, and gives up after 3 seconds in the background.

FormatWhen
MarkdownThe path ends in .md or .mdx, or the request accepts text/markdown
llms.txtThe path is llms.txt or llms-full.txt
HTMLAnything else

Each request records the path without its query, the host, user agent, Accept header, referrer, agent and format. The IP address is sent to check crawlers against their operators' published ranges, and isn't stored.

Keep in mindWhy
A read isn't a citationVisitors sent from AI are the sign an answer linked to you
User agents can be copiedOpenAI, Anthropic, Google, Perplexity, Apple, Microsoft, Common Crawl and DuckDuckGo crawlers are checked against their IP ranges; others can't be
A CDN in front of your host can hide the client addressReal crawlers can then look like impersonators
Fetches a person triggers may ignore robots.txtCrawlers such as GPTBot follow it; in-chat fetches often don't
Apps that strip the referrer and utm_sourceTheir visitors show as direct traffic
Static hosts without middlewareGitHub Pages, S3 and closed docs platforms can't report crawler requests

Every Monday at 9:00 AM UTC, owners, admins and members who turned it on get a weekly summary email covering the previous Monday to Sunday in each website's reporting timezone. It includes an AI traffic section when AI read your websites. Organizations that post investigations to Slack also get a shorter version in those channels. Owners and admins turn it off for everyone under Settings → Notifications → Weekly summary; anyone turns it on or off for themselves under Your emails.

How is this guide?