You are building an agent, and halfway through a task it needs something it cannot do alone: look up a domain, read a web page, check a link. A paid API exists for it. The problem is the sign-up page. It wants an email address, a confirmation click, a card number and maybe a captcha, and all of that is designed to keep software out.
This guide is for developers who want an agent to buy small things on its own. It compares the three practical ways to do it and is honest about where each one fits.
In short: If the agent always uses the same few APIs, sign up once yourself and give it scoped keys. If it needs to pick up tools it finds while it works, a pay-per-call protocol called x402 lets it pay for single requests in USDC with no account or key. Give it a separate small wallet and a spending cap either way. We run an x402 shop, so we have a stake in this; the comparison below says when x402 is the wrong choice.
Why agents get stuck at the sign-up page
Most APIs are sold the same way: create an account, verify an email, add a card or buy credits, then copy a key into your code. That works when a person chooses the API in advance. It breaks when the agent discovers the tool at run time, because every step assumes a human is there.
There are only three ways around it, and they differ in who signs up, who holds the money and what happens if something goes wrong.
Option 1: you sign up once and give the agent a key
The traditional route. You create the account, store the key where your tool code can read it, and the agent calls the API through a function you wrote.
- Good for: a known, short list of APIs the agent uses every day.
- Setup: one account and one key per provider, plus whatever plan or credit each one requires.
- Risk: a leaked key can run up charges until you notice. Use keys with the narrowest scope and the lowest limits the provider offers, and keep them out of prompts and logs.
- Where it falls short: the agent cannot use anything you did not sign up for in advance.
Option 2: one account that covers many APIs
Some services resell many APIs behind a single account and a single balance. You top up once and the agent can call anything in their catalogue.
- Good for: an agent that needs variety, as long as everything it needs is in that one catalogue.
- Setup: one account, one key, one balance.
- Risk: the same as any key, and you depend on that one company's prices and uptime.
- Where it falls short: tools outside the catalogue are still behind a sign-up page.
Option 3: pay per call with x402
x402 uses the HTTP status code 402 Payment Required. The server answers an unpaid request with 402 and its price. The client signs a payment for exactly that amount, sends the same request again, and gets the result. No account, no key, no plan.
- Good for: occasional small calls to tools the agent finds while it works.
- Setup: a wallet used only by the agent, a little USDC (a dollar-pegged stablecoin) on the Base network, and an x402 client library.
- Risk: the wallet key is now the thing to protect. Keep only a small balance in it and set a cap on each payment.
- Where it falls short: only sellers that support x402 can be paid this way, and there is no card-style chargeback. Each seller decides what happens when a call fails.
The step-by-step version of the protocol, with a real 402 answer you can fetch for free, is in our guide What is x402?.
Which one should you pick?
| Your situation | Best fit |
|---|---|
| The agent uses the same two or three APIs every day | Option 1: your own scoped keys |
| It needs many APIs and one provider has them all | Option 2: one account, one balance |
| It finds tools at run time and makes small, irregular calls | Option 3: pay per call with x402 |
| Steady, heavy use of one API | Option 1, usually on a plan |
You can mix them. Many agents use their own keys for the core tools and x402 for the long tail.
What paying per call looks like in code
With x402 the agent's code barely changes. A wrapper around fetch sees the 402, signs the payment and retries. This is the Node example from our guide How can an AI agent pay for an API?, which was run against a local test seller with no real money:
// npm i @x402/fetch @x402/core @x402/evm viem
import { wrapFetchWithPayment } from '@x402/fetch';
import { x402Client } from '@x402/core/client';
import { ExactEvmScheme } from '@x402/evm/exact/client';
import { privateKeyToAccount } from 'viem/accounts';
const signer = privateKeyToAccount(process.env.AGENT_WALLET_KEY);
const client = x402Client.fromConfig({
schemes: [{ network: 'eip155:8453', client: new ExactEvmScheme(signer) }],
spendControls: { maxAmountPerPayment: '$0.005' }, // refuse anything dearer
});
const pay = wrapFetchWithPayment(fetch, client);
const r = await pay('https://shop.lordevo.com/api/quick/dns-lookup?host=example.com&type=MX');
console.log(r.status, await r.json());
Three things matter here. The private key comes from an environment variable, never from the prompt. The cap refuses any payment above $0.005 before anything is signed. And the model never sees the wallet: your code holds the key, and the model only chooses which tool to call.
Or use our SDK
If the agent mostly calls our shop, the lordevo-x402 client (version 0.1.5) does the same steps and gives each tool its own method. maxPriceUsd makes it refuse any tool priced above $0.005.
npm i lordevo-x402@0.1.5
# for paid calls, also:
npm i @x402/fetch @x402/evm viem
import { fromPrivateKey } from 'lordevo-x402';
const lordevo = await fromPrivateKey(process.env.AGENT_WALLET_KEY, { maxPriceUsd: 0.02 });
const r = await lordevo.dnsLookup({ host: 'example.com', type: 'MX' });
console.log(r);
The shop's framework guides (LangChain, CrewAI, the Vercel AI SDK, MCP clients and more) are at shop.lordevo.com/guides/sdk.
What it costs
Prices are set per call by each seller and stated in every 402 answer. In our Lordevo Shop, 58 quick tools cost from $0.0021 to $0.005 per call. At those prices:
| Balance | DNS lookups at $0.0021 | Site checks at $0.005 |
|---|---|---|
| $0.10 | 48 | 20 |
| $1 | 476 | 200 |
| $5 | 2,381 | 1,000 |
With the common USDC setup, the wallet does not need ETH for gas. It signs an authorisation, and a facilitator service submits the payment and pays the network fee.
Before you let it pay unattended
- Use a new wallet for the agent only. If the key leaks or the agent loops, the loss stops at whatever you put in it.
- Cap every payment. Recent x402 client versions (2.23.0 or later) support a per-payment cap, as in the code above.
- Add a total budget. A cap per payment does not stop an agent from making many cheap calls in a loop. Count spending in your tool code and stop at a limit.
- Know the seller's failure rule. In our shop, an answer with status 400 or higher is never settled, so a failed quick call costs nothing. Long jobs that answer 202 are the exception: they are charged when the job is accepted and are not refunded automatically if they fail later. If a paid job failed, email hello@lordevo.com with the transaction hash and we'll review it, usually within 2 business days. The details are in what happens when an x402 call fails.
Try it without a wallet
You can see a real result before you set anything up. Add trial=1 to a request for 3 free calls per IP address per UTC day, on tools priced up to $0.0022:
curl "https://shop.lordevo.com/api/quick/dns-lookup?host=example.com&trial=1"
When that returns what your agent needs, the shop's start page has copy-paste setups for curl, JavaScript, Python and MCP, and llms.txt lists every tool with its price and parameters in a form an agent can read.
Key takeaways
- Sign-up pages are built for people, so an agent cannot get past them on its own.
- Your own scoped keys suit a short, fixed list of APIs.
- One multi-API account suits variety within one catalogue.
- x402 lets an agent pay for single calls with no account, in USDC on Base, if the seller supports it.
- Whatever you choose, keep the key away from the model, use a small separate wallet or budget, and cap spending.