How to Use a Pay-Per-Call API for AI Agents with x402
· 3 min read
A pay-per-call API charges your AI agent a small amount for each request instead of a monthly plan. With x402, the agent pays in USDC as part of the request itself, and before it pays, it can check whether the endpoint is worth paying with Lumière PayCheck.
How pay-per-call works with x402
x402 uses the HTTP status code 402, "Payment Required." The flow has three steps:
- Your agent calls the API without paying.
- The API answers 402 with a quote: the price, the network (most often Base), the token (USDC) and the wallet to pay.
- Your agent pays that quote and sends the request again with proof of payment. The API returns the data.
There's no account, no API key and no invoice. That's what makes it work for agents: they can pay for exactly what they use, one call at a time.
The problem: paying doesn't mean you got anything
A 402 quote or a payment receipt only shows that money moved. It doesn't show that the data arrived. An endpoint can take the payment and return an error, an empty answer, or the wrong data. A seller's payout wallet can also change without warning, which is how a hijacked endpoint usually shows up first.
Your agent can't tell any of this from the quote alone. That's the gap Lumière PayCheck fills.
How Lumière PayCheck checks an endpoint
PayCheck monitors more than 128,000 x402 endpoints, including every one listed in the x402 Bazaar. For each one, it:
- checks that the 402 quote is valid and that the price and payout wallet stay stable;
- makes real paid test calls to confirm the endpoint delivers what its listing promises;
- reads real USDC settlements on Base and Solana into the payout wallet, to see 30-day volume and how many independent buyers there are;
- flags payout-wallet changes (a possible hijack), price increases and lookalike sellers;
- screens wallets against the OFAC sanctions list.
Every paid test PayCheck makes comes with a signed receipt (Ed25519). Anyone can look them up at GET /v1/test-receipts?url=<endpoint>.
PayCheck never touches your money. It doesn't process, route or hold payments. It only tells your agent whether to pay.
How to add the check to your agent
For a quick manual check, paste any x402 URL into the free checker at https://lumierepaycheck.org/check. You'll see the grade, uptime, price history and payout-wallet history.
For your agent, call the free check-payment endpoint (POST /v1/check-payment) with the URL, amount and payTo from the 402 quote, before paying. It returns allow or deny, with the reason. Pay only when it says allow.
After paying, report whether you got what you paid for. That keeps the grades current for the next agent.
Using MCP? Connect your agent to https://lumierepaycheck.org/mcp (streamable HTTP), or run the npm package lumiere-paycheck-mcp over stdio. The tools include check_endpoint, check_payment and report_outcome.
What the verdicts mean
Each endpoint gets a score from 0 to 100 and a verdict:
- Proceed: monitoring and testing look good.
- Caution: something needs a second look, such as a recent price or wallet change.
- Avoid: the endpoint has failed checks, so paying it is likely to waste money.
Some endpoints get other labels instead, such as not enough data yet, or a bulk listing (a seller that lists a very large number of endpoints at once).
FAQ
What is x402? An open payment protocol built on HTTP 402. An API quotes a price, the client pays in a stablecoin like USDC, and the API returns the response. It's designed for AI agents paying for APIs per call.
Does PayCheck hold my money? No. PayCheck never moves anyone's money. It checks the endpoint and returns a verdict, and your agent decides whether to pay.
Does checking cost anything? The checker, the check-payment endpoint and the MCP checks are free.
Check an x402 endpoint for free at https://lumierepaycheck.org/.
More from the blog
We paid x402 endpoints 45,152 times. Here's what we found.
Six weeks of real paid calls to 37,812 x402 endpoints from 2,307 sellers. 95% delivered once paid, but half of all payment attempts never went through.
How to make your x402 endpoint payable from browser-based agents
Browser based AI agents face specific technical barriers when attempting to pay for API access using the x402 protocol. Without proper Cross Origin Resource…
Top Endpoints Command $18,000 in Monthly Payments for AI Agents
The most active x402 endpoints on Lumière PayCheck are generating significant revenue, with the single highest performing API processing nearly $18,000 in…