Skip to main content
HomeLanding pagesAI agent pay-per-call setup: the fix
LANDING PAGE

AI agent pay-per-call setup: the fix

7 min read·Last updated June 2, 2026

To set up an AI agent to pay per call, use x402, which is inherently per-call: each request settles its own payment in USDC with no subscription. Wrap createX402Client in a tool the agent calls, fund its wallet, and size the spend limit so per-call payments stay bounded. The agent then pays only for what it uses, call by call, which matches how agents actually consume services.

The problem

You want your AI agent to pay per call, for each API call, tool use, or service request it makes, rather than committing to a subscription. The trouble is that the payment models you know are built around accounts and recurring fees: sign up, get a key, pay monthly. None of that is per-call, and none of it fits an agent that should pay only for the individual calls it actually makes, often to services it has never signed up for.

This is the pay-per-call-setup problem. It is less about a failure and more about a model: you know what you want, payment that tracks individual usage, but the standard account-and-subscription setup does not provide it, and you are not sure how to set up true per-call payment. The symptom is wanting to charge or pay per call with no clean way to do it, and the fix is to use the mechanism that is per-call by design.

Why per-call fits agents

Per-call payment fits agents because it matches how agents consume services. An agent makes many small, varied calls as it works, some tasks need a few, some need hundreds, and it often calls services it never anticipated when it started. A subscription assumes a known, ongoing relationship and a flat fee, which is a poor match for that bursty, unpredictable, signup-free pattern. Per-call payment, by contrast, charges for exactly what the agent uses, when it uses it.

It also unlocks reach. With per-call payment and no signup, an agent can pay a service it has never encountered on first contact, which a subscription model cannot, since there is no account to create mid-task. And per-call suits micropayments: many agent calls are worth a fraction of a cent, which a subscription cannot price sensibly but a per-call stablecoin payment can. So per-call is not just one option for agents; it is the model that fits their usage, their reach, and their economics, which is why setting it up is worth doing right.

The fix

The fix is straightforward because the right tool is already per-call: use x402. The x402 protocol settles each request individually, so an agent that pays over x402 is paying per call by construction. You wrap createX402Client from @blockchain0x/x402 in a tool the agent calls; when a call hits an HTTP 402, the client settles that one call's payment in USDC on Base and retries, and the agent moves on. There is no subscription, no account, just a payment per call.

So there is no separate per-call mode to enable; setting up x402 payment is setting up per-call payment. The agent pays for each call it makes and nothing more, to any service that speaks x402, including ones it has never signed up for. The fix to the want-per-call problem is therefore to wire the x402 client, which gives you the per-call behavior inherently. The general payment setup is in how-to-add-usdc-payments-to-ai-agent, and the closely related cannot-pay case in ai-agent-cannot-pay-for-api.

How to set it up

The setup is the standard agent-payment wiring, which is per-call by nature. Create the agent and fund its wallet with USDC, on Base Sepolia while you build. Set a spend limit sized for per-call usage. Then wrap the x402 client in a tool:

TYPESCRIPT
import { createClient } from "@blockchain0x/node";
import { createX402Client } from "@blockchain0x/x402/client";

const sdk = createClient({ apiKey: process.env.B0X_API_KEY! });
const fetchWithPay = createX402Client({ sdk });

// Each call settles its own payment per call:
const res = await fetchWithPay("https://api.example.com/paid-endpoint");

Add that tool to the agent. Every call the agent makes through it pays for that call alone, the per-call behavior you wanted, with no extra configuration. For Python frameworks, the same client runs behind a small local proxy the agent's tool calls. The setup is identical to general x402 payment, because per-call is not a feature you add but the way x402 works.

Verify it works

Confirm per-call behavior with a couple of calls on testnet. With a sk_test_ key and a funded wallet, have the agent make one paid call and confirm a single payment settles for it, then have it make a second call and confirm a second, separate payment. Seeing one payment per call, rather than a single charge for access, is the proof that per-call is working as intended.

Check the dashboard for the matching payment.sent events, one per call, which makes the per-call pattern visible: the agent's spend is a series of individual call payments, not a subscription charge. If you see no payments, the wallet may be unfunded or the spend limit too low; if you see a payment but no data, check the endpoint. Once each call produces its own settled payment on testnet, the per-call setup is verified, and swapping to a sk_live_ key moves it to mainnet unchanged.

Per-call economics

Setting up per-call payment means thinking about per-call economics, because the cost model is now usage-based. Each call costs a small amount, and the agent's total cost is the sum of its calls, so spend tracks activity directly, a quiet but real advantage, since you pay for exactly what the agent does. There are no flat fees for unused access and no overage surprises beyond what the agent actually called.

The control for this is the spend limit, sized for per-call usage. Set the per-transaction cap at the most a single call should ever cost, which catches a mispriced or runaway call, and the period allowance at a sensible total for the agent's expected work, which bounds the cumulative cost of many small calls. That way per-call payments stay economical and bounded: small per call, capped per call, and limited in total. With the limit sized for the per-call pattern, the agent pays for what it uses while you keep the total within a budget you set, which is exactly the economics per-call is meant to give.

Per-call versus metered billing

It is worth distinguishing true per-call payment from metered billing, since they can look similar. Metered billing also charges by usage, but it does so on an account: the buyer signs up, usage is tracked, and an invoice is sent periodically. True per-call payment, as x402 provides, settles each call immediately with no account and no invoice, which is what lets an unknown agent pay on first contact and what suits autonomous machine traffic.

The difference matters for your setup. If your callers are humans or businesses with an ongoing relationship who expect an invoice, metered billing on accounts may fit. If your callers are autonomous agents that should pay per call with no signup, true per-call x402 is the fit, and that is what this setup gives. So when you set up per-call payment for an agent, you are choosing the no-account, settle-immediately model on purpose, because it matches a payer that cannot sign up and pays as it goes. Knowing which of the two you actually want keeps you from building an account-based system where a per-call one belongs.

If you want your agent to pay per call, the path is the x402 setup. The full walkthrough is in how-to-add-usdc-payments-to-ai-agent, and the closely related problem of an agent that cannot pay an API at all is in ai-agent-cannot-pay-for-api. Together they take you from wanting per-call payment to an agent that pays, call by call, within bounds. Pricing is on the pricing page.

FAQ

Frequently asked questions.

How do I make my AI agent pay per call?

Use x402, which is per-call by design. Wrap createX402Client in a tool the agent calls; when it hits an HTTP 402, the client settles that one call's payment in USDC and retries. There is no subscription or account, so the agent pays for each call it makes and nothing more. Fund the wallet and set a spend limit to bound the per-call payments.

Is per-call payment different from a subscription?

Yes. A subscription charges a recurring fee for access regardless of usage; per-call charges for each individual call. For an agent, per-call usually fits better, since the agent pays only for what it uses, can transact with services it has never signed up for, and its cost tracks its activity. x402 is a per-call mechanism, which is why it suits agents.

Do I need a separate setup for per-call versus other payment?

Not really, because x402 is already per-call. Setting up x402 payment for your agent is setting up per-call payment, there is no extra mode to enable. You wrap the x402 client in a tool, fund the wallet, and bound it; the per-call behavior is inherent to how x402 settles each request. The same setup that lets the agent pay makes it pay per call.

How do I keep per-call payments from adding up?

Set a server-side spend limit sized for per-call usage: a per-transaction cap at the most a single call should cost and a period allowance for the agent's expected total. Per-call payments are small individually but frequent, so the period allowance is what bounds the cumulative total, ensuring many small calls cannot exceed a budget you set.

What does the agent pay per call in?

USDC on Base. Each call settles in USDC, the dollar-pegged stablecoin, so per-call amounts are economical even at sub-cent sizes, which card rails cannot price. The agent pays from its wallet, and because settlement is on a low-fee chain, paying for many small calls is viable, which is what makes per-call the practical model for agents.

Create your free agent wallet in 5 minutes.

First payment confirmed in under ten minutes. Free to start.