# How AI agents pay for APIs: keys, credits, capped tokens, x402 | agentic402

> How AI agents pay for APIs: four models compared on setup, spending limits, leaks and who pays for failed calls, with quotes from Apify, Firecrawl and Jina.

Source: https://agentic402.dev/guides/how-ai-agents-pay-for-apis/

Published 3 December 2026 · Updated 3 December 2026

How AI agents pay for APIs today comes down to four models: an API key on a human's account billed monthly, prepaid credits on that account, a temporary token with a fixed spending cap bought through a payment protocol, or a payment on every request with x402. The first two need a person to sign up. The last two let an agent pay on its own. They differ most on spending limits, on what a leak costs, and on who pays when a call fails.

## The four models side by side

*How an agent pays for an API. "Human setup" means a person must create an account first.*

| Model | Human setup | Spending limit | If the credential leaks |
|---|---|---|---|
| API key, billed monthly | Yes | Whatever the provider's dashboard offers | Spend on your account until revoked |
| Prepaid credits | Yes | The credit balance | The remaining credits |
| Capped token via a payment protocol | No | The token's cap | The rest of that token's cap |
| Pay per request (x402) | No | The wallet's balance, plus any client limits | The wallet key leaking costs the wallet's balance. There's no API credential to leak |

The rest of this guide goes through each model with a real example from a provider's own documentation, then the question most comparisons skip: what happens to the money when the call doesn't work.

## API keys on a human account

This is how almost every API works: a person signs up, adds a card, creates a key, and puts the key in the agent's configuration. The agent sends the key with each request, and the provider bills the account at the end of the month, or draws down a plan.

It works, and for an agent that one company runs against a handful of known services it may be all you need. The weaknesses show when agents act on their own. The agent can only use services a person signed up for in advance. Each key is a standing credential: until someone rotates it, anything that reads it, a log file, a prompt-injected tool, a careless commit, can spend on the account. And the limit on spending is whatever controls the provider's dashboard happens to have.

## Prepaid credits

Many APIs sell credits up front: buy a block, and each call draws it down. Credits put a ceiling on the damage a leaked key can do, which is a real improvement. They still need the human signup and the card, and they bring their own waste: credits bought for an experiment that never ran, or a plan sized for a peak month.

Firecrawl's pricing is a typical example of a credit model, with monthly plans that include a set number of credits. Our [Firecrawl comparison](https://agentic402.dev/compare/firecrawl-alternative/) works through what a page costs at each plan.

## Capped tokens bought by the agent

A newer model lets the agent buy access itself and receive a temporary key. Apify's agent payments documentation describes it: "Agentic payments let an AI agent pay for Actor runs on its own, without signing up for Apify or a person setting up billing." The mechanism: "An agent pays once through a supported protocol, and AGI returns a temporary Apify API token with a fixed spend cap."

The cap is the safety feature. Apify again: "The token balance is a hard spending cap, the token expires 14 days after you buy it, and unused balance is non-refundable." Apify also says "Agentic payments are experimental and may change." So the agent pays in advance for a budget, uses it like an ordinary key, and loses whatever it doesn't spend in two weeks. It suits a platform with many tools behind one key, where one purchase covers a whole session of work. It's less tidy for an agent that needs one call from each of many providers.

## Paying for each request with x402

With x402, the payment is the authorization. The agent calls the API, gets `402 Payment Required` with a price, signs a stablecoin payment for exactly that amount, and repeats the request. There is no account, no key and nothing prepaid, and the same wallet pays any server that speaks x402. [What is x402](https://agentic402.dev/guides/what-is-x402/) walks through a real 402 response field by field.

The agent needs a wallet and an x402 client library. Its spending limit is the wallet's balance, plus whatever checks the client applies before signing. Alchemy's overview of agent payments states the principle well: "A good agent payment system does not hand an agent an open wallet." It goes on: "It gives the agent a way to pay, plus spend caps, allowlists, and rules that keep spending predictable and auditable."

x402's weak point is at the small end. Each payment is settled on a blockchain through a facilitator, which charges per settlement. Agentic402's facilitator, PayAI, listed $0.0015 per transfer on Base on 3 December 2026. At that rate the fee is 30% of a $0.005 call and more than a $0.001 call, which makes very cheap calls poor value as single payments, where a credit model has no such floor.

## Who pays when the call fails

An agent makes mistakes and the web is unreliable: sites time out, block bots, return errors. How a provider treats failed calls decides how much an agent wastes. The rules differ, so here they are as each provider states them, checked on 3 December 2026:

*Charging for failed calls, quoted from each provider's pages on 3 December 2026*

| Service | Model | Failed calls |
|---|---|---|
| Firecrawl | Credits | "A page that responds with an error status such as 403 or 404 is still returned to you and costs 1 credit" |
| Jina Reader | Tokens on an API key | "No, tokens are not deducted for failed requests" |
| Apify (capped token) | Prepaid token | Not stated (the page covers unspent balance, not failed calls) |
| agentic402 | x402 per request | Any response of 400 or above is never settled, so it costs nothing |

None of these is wrong. Firecrawl did fetch the 404 page, and it returns it to you. But they lead to different behaviour. Under a charge-for-errors model, an agent should check URLs before scraping them. Under a never-charge-errors model, it can simply try.

With x402, the answer depends on the server, not the protocol. A server can verify the payment, run the work and settle only on success, as agentic402 does. It could also settle first and fail afterwards. One developer guide lists this as a risk to plan for: "The endpoint is down or broken, and the agent pays for nothing." Check each provider's stated policy before an agent relies on it. [agentic402's payment rules](https://agentic402.dev/docs/payments/) spell out what is charged.

## Setting spending limits that actually hold

Whatever the model, the limit that matters is the one the agent can't talk its way around. Three work in practice.

**A dedicated wallet with a small balance.** For x402, this is the simplest and strongest limit. Give each agent its own wallet, fund it with what it may spend this week, and top it up on a schedule. A runaway loop or a stolen key can't take more than is there.

**Per-payment and per-day caps in the client.** x402 client libraries let your code inspect each offer before signing. The same developer guide recommends: "Set a cap per payment and per day, so one bad endpoint or a loop can't drain the wallet." Refuse offers above the price you expect, and count what the agent has paid today.

**An allowlist of services.** Only sign payments to recipients and endpoints you've approved. An agent that has been tricked into calling an unknown paid endpoint then gets a refusal from its own client instead of a charge.

For API keys and credits, the equivalent is a separate account or project per agent, with the provider's own spending limits set as low as the work allows. Whatever you choose, review what the agent actually spent each week. A limit nobody looks at only tells you about a problem after it has cost the full amount.

## The secret each model asks the agent to hold

Every model leaves the agent holding something that can spend money, and where that secret lives matters as much as the model. With API keys and credits, it's the key string. With a capped token, it's the temporary token. With x402, it's the wallet's private key, which signs every payment.

Keep all of these out of the model's context. An agent that can read its own key in a prompt can be tricked into repeating it: a fetched page or a webhook body with the right instructions, and the key ends up in a tool call to somewhere it shouldn't go. The safer pattern is to keep the secret in the tool layer. The model decides to call a paid API. The code around it holds the key or the wallet, applies the limits and signs. The model never sees the secret at all.

Store the secret where your other production secrets live, an environment variable injected at runtime or a secret manager, never in code, a config file in the repository or the agent's memory. For x402, a leaked wallet key loses at most what's in the wallet, which is one more reason to keep the balance small.

## Quiet months and busy months

Plans and prepaid credits are bets on volume. A plan sized for a busy month is paid in full in a quiet one. Credits bought for a project that stalls sit unused, and Apify's capped tokens expire after 14 days. Paying per request turns that bet off: a month with no calls costs nothing, and a month with ten times the calls costs ten times as much, with no plan to upgrade.

That makes per-request payment a good fit for agents whose work is irregular by nature, such as research on demand, support agents that only act when something breaks, or monitoring that wakes up when a deadline nears. Steady, predictable, high-volume work is where plans earn their discount.

## Which model to choose

For a single agent that a company runs against a few services it already pays for, keep the keys you have. The setup is done, the invoices go to finance, and the agent never needs to buy anything new.

For agents that pick their own tools while they work, calling services nobody signed up for in advance, a model without human setup is the only one that works: a capped token where a platform offers it, or x402 where the service supports it. x402 has the advantage that one wallet works with every x402 service, while capped tokens are bought per platform.

For high-volume calls at fractions of a cent, credits or plans are usually cheaper, because per-payment settlement fees don't apply. For calls of half a cent and up, priced per use and made irregularly, paying per request avoids both the plan you don't use and the credential you have to guard. [API keys vs x402](https://agentic402.dev/compare/api-keys-vs-x402/) goes deeper on the security side of that choice.

## What this looks like on agentic402

All five agentic402 tools use x402 only: there are no keys or accounts to sign up for. Paid calls cost $0.005, or $0.01 to create an inbox, in USDC on Base, and free calls such as reading an inbox or a memory space need only the token the paid call returned. Failed calls are never settled. [The price list](https://agentic402.dev/pricing/) has every endpoint, and [the quickstart](https://agentic402.dev/docs/quickstart/) shows a first paid call in under twenty lines of JavaScript.

## Questions about agent payments

**Can an AI agent pay with a credit card?**
Only through a person's account or a card issued for it. The card has to be set up by someone, and most APIs still expect an account behind it. Wallet-based payments are the way for an agent to pay with nobody setting anything up in advance.

**Does the agent need cryptocurrency?**
For x402, it needs a stablecoin balance, typically USDC, in a wallet. With the `exact` scheme on Base it doesn't need ETH for gas, because the facilitator submits the transfer.

**Can agents pay each other?**
Yes, if one of them runs an x402 server. Any agent with a wallet and an x402 client can pay any x402 endpoint, whether a company or another agent operates it.

**How do I stop an agent overspending?**
Give it its own wallet with a small balance, cap each payment and each day in the client, and only allow payments to services you've approved.

Cite this page: agentic402, "How AI agents pay for APIs", https://agentic402.dev/guides/how-ai-agents-pay-for-apis/, published 3 December 2026. Quotes are from Apify, Alchemy, Firecrawl, Jina, PayAI and a DEV Community guide as read that day.

## Related

- [What is x402?](https://agentic402.dev/guides/what-is-x402/)
- [API keys vs x402](https://agentic402.dev/compare/api-keys-vs-x402/)
- [What agentic402 charges, and when](https://agentic402.dev/docs/payments/)
- [Agent memory API with no account](https://agentic402.dev/tools/memory/)
