←Back/Product/Vercel BotID
IntermediateProduct

Detect Automated Abuse on AI Routes with Vercel BotID

Add BotID to an expensive AI route, observe its classifications, and decide how to handle automated traffic before inference.

Detect Automated Abuse on AI Routes with Vercel BotID

Bot ID ensures that there's proof that the request came from your app... this has to be put on the actual route... But you can run it for a little bit, see what your user profiles look like, tune it, and then ultimately block things.

Before you start

About 60 minutes

What you need

  • The API route for your AI chat endpoint (e.g., `/api/chat`)

What you’ll make

A monitored bot-detection check on an AI endpoint, with a considered response to requests classified as bots.

Tools used

  • Vercel BotID

    Vercel BotID helps applications detect automated traffic on protected routes using client challenges and server-side checks.

    VisitVercel BotID

The workflow

Follow the sequence once, then adapt the prompts, checks, and handoffs to your own setup.

5 steps

Step 01

Identify Critical API Routes

Determine which of your API endpoints trigger expensive LLM calls. This is typically the main chat or generation route.

Protecting only your login page is not enough; the protection must be on the route that incurs the cost.

Step 02

Configure and Observe BotID

Install and configure BotID for the route and method on the client, then call checkBotId() in the server handler before the model call. Start by logging the result without blocking traffic.

Keep existing authentication and authorization checks; BotID does not establish whether a request is authorized.

Step 03

Review Classifications

Review classifications and relevant request logs over a representative period. Investigate flagged requests and legitimate traffic that may be affected.

Avoid recording sensitive request contents unnecessarily.

Step 04

Decide How to Handle Flagged Traffic

Choose a response for requests classified as bots and decide how to handle verified or otherwise trusted automation. Test the client and server configurations on the exact route and method.

A bot classification is a signal, not proof of fraud.

Step 05

Apply and Monitor the Policy

Once tested, update your server handler to reject or otherwise handle requests flagged by checkBotId(), before the expensive model call. Monitor results and adjust your policy as needed.

Watch for false positives and support reports; legitimate automated clients may need a deliberate exception.

What good looks like

  • BotID is configured on the intended route and method.
  • The server checks and records bot classifications before inference.
  • The response to flagged traffic is tested and monitored for false positives.

Build your next product with ChatPRD

Turn an idea into a PRD, user stories, and a plan.

Try ChatPRD free

Runbook notes

How to recover when the loop fails and where human judgment helps.

If it goes sideways

The tool is configured too aggressively and blocks legitimate users, particularly those on unusual networks or using accessibility tools that might alter the client signature.
Revert the tool to observation-only mode. Analyze the logs for the false positives to understand the pattern. Adjust the tool's tuning to be more permissive or create an allowlist for specific user agents or IP ranges.

Human checkpoints

Let routine work keep moving.

  1. Review traffic logs and user profiles during the observation period before enabling blocking mode.

Start shipping better products.

Join 250,000+ product managers who use ChatPRD to write better docs, align teams faster, and build products users love.

Free to start · 14-day Pro trial · SOC 2 Type II