# API keys vs x402: accounts, leaks, limits and failed calls | agentic402

> API keys vs x402: a key bills an account later; x402 pays for each request now. Compared on setup, what a leak costs, spending limits and failed calls.

Source: https://agentic402.dev/compare/api-keys-vs-x402/

Published 3 December 2026 · Updated 3 December 2026

API keys vs x402 in one line: an API key identifies an account that is billed later, while an x402 payment pays for the request itself, now, from a wallet. Keys suit steady use by a team that has signed up. X402 suits agents that call services nobody signed up for in advance. Neither is safer by default: a leaked key spends until it's revoked, and a leaked wallet key spends what's in the wallet.

## The difference in one sentence each

2s.io describes the first model plainly: "An API key authenticates a pre-registered account." Quicknode, which sells both kinds of access, describes the second: "A wallet becomes the identity, and the payment is the authorization." Everything else in this comparison follows from that: who has to do what before the first call, what a stolen secret can do, and who carries the cost of a call that goes wrong.

*API keys and x402 compared*

|  | API key | x402 |
|---|---|---|
| Before the first call | Sign up, add billing, create a key | Hold a funded wallet and an x402 client |
| What travels with each request | The same reusable key | A signed authorization for one payment |
| Who is identified | An account | A wallet address |
| When money moves | Later, on an invoice or against prepaid credit | At the request, when the server settles |
| What a leaked secret can spend | Up to the account's limits, until revoked | The wallet's balance (the wallet key). A captured payment authorization is for one amount, one recipient |
| Spending limit | Whatever the provider's dashboard offers | The wallet balance plus client-side caps |
| Smallest sensible price | Fractions of a cent, billed in bulk | Bounded by the settlement fee per payment |
| Failed calls | Provider's policy | Server's policy (settle only on success, or not) |

## Setup: who has to do what

With API keys, a person does the work up front. 2s.io lists it: "The traditional model is: sign up, get an API key, pick a plan, manage quotas, rotate secrets." For one service that's an afternoon. For an agent that might want ten services it has never used, it means a person signing up for ten things in advance, and the agent being unable to use an eleventh.

With x402, the setup is a wallet and a client library, once. Quicknode's summary of x402 access is "No account. No API key. No registration." The agent can then pay any x402 server it finds, at the price the server states in its 402 response. [What is x402](https://agentic402.dev/guides/what-is-x402/) walks through that response field by field, and [our quickstart](https://agentic402.dev/docs/quickstart/) goes from an empty wallet to a paid call.

## What a leak costs

An API key is a bearer credential: whoever holds it can use it, as often as they like, until someone notices and revokes it. Keys leak in ordinary ways: committed to a repository, printed in a log, pasted into a support ticket. For agents there's a newer way: a prompt-injected page or tool result persuades the model to repeat a key it can see. The damage is bounded by the account's limits, which often aren't set.

x402 changes what's exposed. The thing sent with each request is a signed authorization for one payment of one amount to one recipient, so an intercepted request is worth at most that one payment. The secret that matters is the wallet's private key, and a stolen wallet key can spend everything in the wallet. That's why the usual advice is a dedicated wallet per agent with a small balance: the worst case is then a known, small number.

An analysis of the two for agents reaches a balanced verdict: "Neither x402 nor traditional API keys are categorically safer for AI agents." It also notes that "x402 instead uses a signed payment authorization in the payment flow" in place of a reusable key, and that "Neither choice removes the need for separate controls over what the agent is allowed to do."

The practical rule is the same for both: keep the secret out of the model's context. Let code around the model hold the key or the wallet and make the calls, so no prompt can talk the model into repeating it.

## Spending limits

With API keys, the limit is whatever the provider lets you set on the account. With prepaid credit, the balance is the cap. With x402, the wallet balance is a hard cap that no provider can override, and the client can add its own: refuse any single payment above a set amount, stop after a daily total, pay only an allowlist of recipients.

One limit x402 doesn't give you is per-service spending inside one provider's account, such as "this key may only use endpoint A". With keys, some providers offer scoped keys for that. With x402, you build the equivalent in the client by deciding which offers to sign.

## Pricing and the fee floor

API keys put no floor under the price of one call. A provider can bill a thousandth of a cent per request and settle the total monthly, because there's one charge on one card. x402 settles every paid request separately, through a facilitator that charges per settlement. agentic402's facilitator, PayAI, listed $0.0015 per EIP-3009 transfer on Base mainnet on 3 December 2026. At that rate the fee is 30% of a $0.005 call and more than half of anything under $0.003, which is why [agentic402's prices](https://agentic402.dev/pricing/) start at $0.005.

So for very cheap, very frequent calls, keys and monthly billing remain the economical choice. For calls of half a cent and up, made irregularly, per-request payment avoids plans and minimums.

## Failed calls

Neither model decides on its own whether a failed call costs money. The provider does. Under keys, policies differ: Firecrawl's pricing page says "A page that responds with an error status such as 403 or 404 is still returned to you and costs 1 credit", while Jina's Reader page says "No, tokens are not deducted for failed requests."

x402 adds a structural option. Because payment is verified before the work and settled after, a server can simply not settle when the work fails, and the signed authorization expires unused. agentic402 does this for every response of 400 or above. A server could also settle first. The protocol allows both, so check the provider's stated policy. [agentic402's payment rules](https://agentic402.dev/docs/payments/) list what is and isn't charged.

## Privacy

An API key ties every request to an account, usually with a name, an email address and a card behind it. The provider sees all your usage. Outsiders see none, unless the provider shares it.

x402 needs no name or email, but the payments are public. Each one is a USDC transfer on a public chain, so anyone can see that a wallet paid a given address a given amount at a given time. Servers can also log the paying address. Agentic402's application logs record it per call, along with the route, the status and, for fetch, the hostname fetched, but no request bodies or IP addresses. If you don't want your agents' activity linked together, use separate wallets.

## Three incidents under each model

**A secret is committed to a public repository.** With an API key, anyone who finds it can call the API on your account until you revoke it, and the bill arrives later. With x402, there's no API key to commit. The equivalent mistake is committing the wallet's private key, and whoever finds it can move the wallet's balance at once. Revoking and reissuing fixes a leaked key. Only a new wallet fixes a leaked wallet key. In both cases the damage is set by the limit you chose beforehand, which is the argument for small, dedicated wallets and tight account limits.

**An agent gets stuck in a loop overnight.** With a key on a monthly plan, the loop runs until a quota or a rate limit stops it, and the cost shows up on the next invoice. With x402, every iteration is a separate payment, so the loop stops when the wallet runs dry or when a client-side daily cap refuses to sign. Either way, a daily cap is the thing that saves you. X402 just makes it easy to enforce in your own code.

**A fetched page tells the agent to send its credentials somewhere.** If the key or the wallet key is anywhere the model can read, a successful injection can leak it. If the code around the model holds the secret and the model only decides which calls to make, there's nothing for the model to repeat. This one doesn't depend on the payment model at all.

## Running each day to day

Keys need rotation: issue a new one, update every agent that uses it, revoke the old one. A wallet needs topping up and, occasionally, replacing. Moving the remaining balance to a new wallet and updating the agent's configuration is the equivalent of rotation.

Auditing differs too. With keys, the provider's dashboard and invoices are the record of what was spent. With x402, the record is the wallet's transaction history on the chain, which anyone can read and nobody can edit, plus whatever your agent logs about why it paid. Finance teams used to card statements may need a short explanation of the second.

## Tokens that aren't API keys

x402 doesn't remove every token. Resources that outlive one call still need a way back in: on agentic402, creating an [inbox](https://agentic402.dev/tools/inbox/) returns a read token, the first [memory](https://agentic402.dev/tools/memory/) write returns a space token, and a [wake](https://agentic402.dev/tools/wake/) job returns a cancel token. These are bearer tokens too, but they differ from API keys in two ways that matter. Each one opens a single resource, not an account. And none of them can spend money: paid calls still need a payment, so a leaked memory token exposes that space's contents but can't run up a bill.

That split, payment for spending and narrow tokens for access, is a reasonable pattern for any service built for agents.

## Which to use

Quicknode's view is that "The two models are additive, not competitive," and that "The choice between them is about the access pattern, not the actor type."

Use API keys when a team runs steady, high-volume work against services it already pays for, wants invoices, dashboards and scoped keys, and makes calls cheap enough that per-request settlement would cost more than the call.

Use x402 when an agent needs services that nobody set up in advance, when usage is irregular, when you want a hard spending cap that the provider can't change, or when the people running the agent don't want to hand it long-lived credentials. [How AI agents pay for APIs](https://agentic402.dev/guides/how-ai-agents-pay-for-apis/) adds two middle options, prepaid credits and capped tokens, to the comparison.

## Moving an agent from keys to x402

For services that offer both, the change is in the HTTP client. Remove the key header, wrap the client with an x402 library such as `@x402/fetch` for JavaScript, give it the agent's wallet, and set the caps you want before it signs. Free calls keep working without payment, and paid calls now return a 402 that the wrapper handles.

Keep the key-based setup running alongside until you've watched a week of x402 payments and checked them against what the agent did. The wallet's transaction history is your statement. There is no invoice to compare against.

## Questions about API keys and x402

**Can x402 replace API keys completely?**
For services that support it, x402 can be the only credential. Many APIs don't support x402, so most agents will hold both for some time.

**Is a wallet private key more dangerous than an API key?**
It can spend whatever the wallet holds, with no provider able to stop it. An API key can spend whatever the account allows until it's revoked. Keep wallet balances small and both kinds of secret out of the model's context.

**Do agentic402's tools use API keys anywhere?**
No. Paid calls are authorized by x402 payments. Tools that need ongoing access, such as an inbox or a memory space, return a random token when created. It opens that one resource and nothing else.

Cite this page: agentic402, "API keys vs x402", https://agentic402.dev/compare/api-keys-vs-x402/, published 3 December 2026. Quotes are from 2s.io, Quicknode, Position Is Everything, Firecrawl, Jina and PayAI as read that day.

## Related

- [What is x402?](https://agentic402.dev/guides/what-is-x402/)
- [How AI agents pay for APIs](https://agentic402.dev/guides/how-ai-agents-pay-for-apis/)
- [x402 payment on agentic402](https://agentic402.dev/docs/payments/)
- [memory: storage opened by a token, not an account](https://agentic402.dev/tools/memory/)
