DEV Community

GN Tech
GN Tech

Posted on

Give your AI agent a budget before you give it a wallet

AI agents can now pay for APIs on their own with x402: the server answers "402 Payment Required", the agent signs a small USDC payment and tries again. No accounts, no API keys. It's a great idea, until a retry loop, a price change or a tampered payment request empties the wallet.

I run a monitor of the paid x402 APIs that agents can call. On 30 September 2026 it tracked 27,499 of them. 2,777 failed their last health check, and 1,495 charged more than their own directory listing said.

So I built x402-seatbelt: a small, free, open-source npm package that checks every payment before it leaves your machine.

import { wrapFetchWithPayment } from "@x402/fetch";
import { createSeatbelt } from "x402-seatbelt";

const seatbelt = createSeatbelt({
  maxTotalUsd: 2.0,     // budget for all payments
  maxPaymentUsd: 0.05,  // no single payment above 5 cents
  paySafe: true,        // optional: check each payment first
});

const fetchWithPayment = wrapFetchWithPayment(seatbelt.wrap(fetch), client);
Enter fullscreen mode Exit fullscreen mode

What it does:

  • Budget and price cap. A payment that would cross your limit is never sent, so nothing is paid. Parallel payments reserve their amount, so they can't overshoot together.
  • Emergency stop. seatbelt.stop() blocks everything after it.
  • Pay Safe (optional). Asks a free service whether the API is working, whether the price is fair compared with its listing and similar services, and whether the wallet is the one that service normally uses. It answers GO, CAUTION or STOP. Only the URL and payment terms are sent, never your keys or signature.

It has no dependencies and runs on Node 18+, Deno, Bun, Cloudflare Workers and browsers. There's a Python version too: agentseatbelt on PyPI.

Code and docs: https://github.com/gmahar82-stack/x402-seatbelt

I'm the author, and I'd love to hear what limits your agents need that this doesn't cover yet.

Top comments (3)

Collapse
 
swarmagentoperator profile image
SWARM operator •

Reading this from the seller side: I run SWARM, a small x402 seller on Base (six pay-per-call services, one month in, zero real sales so far).

Two things we hit that touch your seatbelt:

The official client now ships its own cap. @x402/core 2.28 added spendControls with a default per-payment limit, and on our $0.002 endpoints it refused to pay, showing the limit as “$0.00”. Anything that turns micro-payments into dollars with two decimals can hit the same wall, so a test case at $0.001-$0.005 for maxPaymentUsd might be worth adding.
On the 1,495 APIs charging more than their listing: we had the reverse. The directory kept showing our report at $2.00 after we cut it to $0.99, because the listing only refreshed when someone paid. So a mismatch isn’t always a seller overcharging; sometimes the directory is just stale.

A question, since you watch 27k endpoints: how many of them get paid by the same wallet more than once? From our own measurements, repeat buyers are what’s missing, not endpoints.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.