BotsRated tools for the Vercel AI SDK
@botsrated/ai-sdk gives an AI SDK agent a pre-payment check for x402 sellers. Before the agent pays, the tool returns what BotsRated last measured about the seller: an unpaid, signed probe with status, whether the 402 was valid, latency, and the observed price and payTo. BotsRated is in beta and covers about 4,800 x402 seller hosts on Base.
Install
npm install @botsrated/ai-sdk ai zod
Requires ai 5 or later and zod 3.25.76+ or 4.1.8+. It depends on @botsrated/x402-preflight.
Free preflight
import { generateText, stepCountIs } from "ai";
import { botsratedTools } from "@botsrated/ai-sdk";
const { text } = await generateText({
model: "openai/gpt-5-mini",
prompt: "Before paying https://blockrun.ai/api/v1/chat/completions, check the seller with BotsRated.",
tools: botsratedTools(), // { botsratedPreflight }, free
stopWhen: stepCountIs(3), // AI SDK 7 also has isStepCount(3)
});
stepCountIs works on AI SDK 5, 6 and 7. AI SDK 7 (Node 22+) also offers isStepCount.
botsratedPreflight takes url (seller URL or host) and, optionally, payTo, network and amount from the 402 option the agent plans to pay. With payTo it also returns decision.action: allow or block (for example, a payTo never seen for that host). covered: false means BotsRated has no data for the host; that is not a judgment of the seller. It calls the free GET /v1/preflight.
Opt-in paid check, capped by a budget
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { BotsRatedClient, botsratedTools } from "@botsrated/ai-sdk";
const client = new BotsRatedClient({ paid: { budgetUsd: 0.02, fetchWithPayment: wrapFetchWithPayment(fetch, x402) } });
const tools = botsratedTools(client); // adds botsratedCheck
botsratedCheck calls /v1/check: $0.001 USDC on Base per call after the first 100 per day, which are free. It stops when the budget you set is spent and reports remainingUsd. See pricing.
Guard every payment
Tools only run when the model calls them. To check every x402 payment, register createPrePaymentGuard().beforePaymentCreation from @botsrated/x402-preflight on your x402Client.
Notes
Results are measured facts, not endorsements. Seller-supplied text is passed back as untrusted data. How probes work: methodology. Source: GitHub.