Add Guard to your agent
Add Guard in three steps. Free, no key. You choose when it warns and when it stops a payment.
Every stack uses the same Guard on the x402 client your agent already pays with: botsrated or @botsrated/x402-preflight 0.2.1. Rules and reason codes →
LangChain
1. Install
pip install "botsrated[x402]"2. Attach
Attach Guard to the x402 client your paid tool uses.
from botsrated import PaymentGuard guard = PaymentGuard(preset="carefulBuyer") # omit preset = warn only, never stops a payment guard.install(x402_client) # the x402 client your agent already pays with3. Tell Guard the URL
get = guard.wrap_get(session.get) # tells Guard which URL is being paid (async: wrap_async_get)
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
Free preflight tool today: botsrated_tools() from langchain-botsrated 0.1.2.
After the 0.3.0 release: attach_payment_guard from langchain-botsrated in one line, plus BOTSRATED_TOKEN for your org policy.
OpenAI Agents SDK
1. Install
pip install "botsrated[x402]"2. Attach
Your
AgentandRunnerstay as they are.from botsrated import PaymentGuard guard = PaymentGuard(preset="carefulBuyer") # omit preset = warn only, never stops a payment guard.install(x402_client) # the x402 client your agent already pays with3. Tell Guard the URL
get = guard.wrap_get(session.get) # tells Guard which URL is being paid (async: wrap_async_get)
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
After the 0.3.0 release: attach_payment_guard from botsrated-openai-agents in one line, plus BOTSRATED_TOKEN for your org policy.
LangGraph
1. Install
pip install "botsrated[x402]"2. Attach
Your graph stays as it is.
from botsrated import PaymentGuard guard = PaymentGuard(preset="carefulBuyer") # omit preset = warn only, never stops a payment guard.install(x402_client) # the x402 client your agent already pays with3. Tell Guard the URL
get = guard.wrap_get(session.get) # tells Guard which URL is being paid (async: wrap_async_get)
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
After the 0.3.0 release: attach_payment_guard from langgraph-botsrated in one line, plus BOTSRATED_TOKEN for your org policy.
Llama Stack
1. Install
pip install "botsrated[x402]"2. Attach
from botsrated import PaymentGuard guard = PaymentGuard(preset="carefulBuyer") # omit preset = warn only, never stops a payment guard.install(x402_client) # the x402 client your agent already pays with3. Tell Guard the URL
get = guard.wrap_get(session.get) # tells Guard which URL is being paid (async: wrap_async_get)
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
After the 0.3.0 release: attach_payment_guard from llama-stack-botsrated in one line, plus BOTSRATED_TOKEN for your org policy.
Google ADK
1. Install
pip install "botsrated[x402]"2. Attach
from botsrated import PaymentGuard guard = PaymentGuard(preset="carefulBuyer") # omit preset = warn only, never stops a payment guard.install(x402_client) # the x402 client your agent already pays with3. Tell Guard the URL
get = guard.wrap_get(session.get) # tells Guard which URL is being paid (async: wrap_async_get)
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
MCP tools: add https://botsrated.com/mcp. Proposed for the ADK docs (pending review): google/adk-docs #2494, an MCP tool page.
After the 0.3.0 release: attach_payment_guard from google-adk-botsrated in one line, plus BOTSRATED_TOKEN for your org policy.
CrewAI
1. Install
pip install "botsrated[x402]"2. Attach
from botsrated import PaymentGuard guard = PaymentGuard(preset="carefulBuyer") # omit preset = warn only, never stops a payment guard.install(x402_client) # the x402 client your agent already pays with3. Tell Guard the URL
get = guard.wrap_get(session.get) # tells Guard which URL is being paid (async: wrap_async_get)
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
After the 0.3.0 release: attach_payment_guard from crewai-botsrated in one line, plus BOTSRATED_TOKEN for your org policy.
Vercel AI SDK
1. Install
npm install @botsrated/x402-preflight2. Attach
import { createPaymentGuard } from "@botsrated/x402-preflight/payment-guard"; const guard = createPaymentGuard({ preset: "carefulBuyer" }); // omit preset = warn only guard.install(client); // your x402Client3. Tell Guard the URL
const paidFetch = guard.wrapFetch(wrapFetchWithPayment(fetch, client));
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
Free preflight tool today: botsratedTools() from @botsrated/ai-sdk. Guide →
After the 0.3.0 release: attachPaymentGuard from @botsrated/ai-sdk in one line, plus BOTSRATED_TOKEN for your org policy.
Microsoft Agent Framework
1. Install
pip install agent-framework-botsrated2. Attach
from agent_framework import Agent from agent_framework_botsrated import BotsRatedPaymentMiddleware agent = Agent(..., middleware=[BotsRatedPaymentMiddleware(["pay_x402"])])3. Tell Guard the URL
Name the tool that pays (here
pay_x402). Guard reads the URL and payTo from its arguments.
Stops a payTo BotsRated never observed, by default. Paying from an x402 client? Use the Python steps.
After the 0.3.0 release: attach_payment_guard from agent-framework-botsrated in one line, plus BOTSRATED_TOKEN for your org policy.
Pydantic AI
1. Install
pip install "botsrated[x402]"2. Attach
from botsrated import PaymentGuard guard = PaymentGuard(preset="carefulBuyer") # omit preset = warn only, never stops a payment guard.install(x402_client) # the x402 client your agent already pays with3. Tell Guard the URL
get = guard.wrap_get(session.get) # tells Guard which URL is being paid (async: wrap_async_get)
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
After the 0.3.0 release: attach_payment_guard from pydantic-ai-botsrated in one line, plus BOTSRATED_TOKEN for your org policy.
Mastra
1. Install
npm install @botsrated/x402-preflight2. Attach
import { createPaymentGuard } from "@botsrated/x402-preflight/payment-guard"; const guard = createPaymentGuard({ preset: "carefulBuyer" }); // omit preset = warn only guard.install(client); // your x402Client3. Tell Guard the URL
const paidFetch = guard.wrapFetch(wrapFetchWithPayment(fetch, client));
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
After the 0.3.0 release: attachPaymentGuard from @botsrated/mastra in one line, plus BOTSRATED_TOKEN for your org policy.
LlamaIndex
1. Install
pip install "botsrated[x402]"2. Attach
from botsrated import PaymentGuard guard = PaymentGuard(preset="carefulBuyer") # omit preset = warn only, never stops a payment guard.install(x402_client) # the x402 client your agent already pays with3. Tell Guard the URL
get = guard.wrap_get(session.get) # tells Guard which URL is being paid (async: wrap_async_get)
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
Free preflight tool today: BotsRatedToolSpec() from llama-index-tools-botsrated 0.1.2.
After the 0.3.0 release: attach_payment_guard from llama-index-tools-botsrated in one line, plus BOTSRATED_TOKEN for your org policy.
Python
1. Install
pip install "botsrated[x402]"2. Attach
from botsrated import PaymentGuard guard = PaymentGuard(preset="carefulBuyer") # omit preset = warn only, never stops a payment guard.install(x402_client) # the x402 client your agent already pays with3. Tell Guard the URL
get = guard.wrap_get(session.get) # tells Guard which URL is being paid (async: wrap_async_get)
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
Free. No key. Runs inside your agent; only the seller's host name reaches BotsRated. You pick the rules.
After the 0.3.0 release: remote_policy for your org policy.
TypeScript
1. Install
npm install @botsrated/x402-preflight2. Attach
import { createPaymentGuard } from "@botsrated/x402-preflight/payment-guard"; const guard = createPaymentGuard({ preset: "carefulBuyer" }); // omit preset = warn only guard.install(client); // your x402Client3. Tell Guard the URL
const paidFetch = guard.wrapFetch(wrapFetchWithPayment(fetch, client));
Omit preset for warnings only. Set fail_open or failOpen to true (keep paying) or false (stop).
Free. No key. Runs inside your agent; only the seller's host name reaches BotsRated. You pick the rules.
After the 0.3.0 release: remotePolicy for your org policy.