Payments for AI Agents: How to Let Your Agent Pay for Any API
Payments for AI agents are the protocols and infrastructure that let autonomous software spend money on API calls without human intervention. Instead of pre-provisioning API keys, seats, or monthly subscriptions for every service an agent might need, a single stablecoin balance funds per-call payments across any compatible endpoint.
What payments for AI agents actually means
When we say payments for AI agents, we mean a system where an agent holds a funded balance, encounters a paid API, negotiates a price, signs a payment, and receives data, all within a single HTTP request cycle. The agent is the payer, not a human clicking through a checkout page.
This is distinct from a developer pre-purchasing API credits on behalf of an agent. In a true agent-payment system, the agent itself authorizes spend at call time, governed by caps and policies the developer sets. The agent can call services it has never used before, without the developer signing up for each one in advance. For a deeper look at how agents hold and manage funds, see the guide on ai agent wallets at /learn/ai-agent-wallets.
Why agents need their own payment rails in 2026
Most APIs still gate access through API keys tied to a human account with a credit card on file. This model assumes a person evaluates the service, agrees to terms, and manages billing. Autonomous agents break every step of that assumption: they discover services at runtime, call them thousands of times per task, and may never interact with the same endpoint twice.
Monthly subscription tiers compound the problem. An agent that needs three calls to a geocoding API and fifty calls to a language model should not pay for two separate $29/month plans. What it needs is pay-per-call pricing settled on infrastructure that can handle sub-dollar amounts without the $0.30 fixed fee of a credit card transaction. Stablecoin settlement on Layer 2 chains like Base costs under $0.001, making per-call billing practical. For more on this model, see the pay per call api pillar at /learn/pay-per-call-apis.
How x402 turns HTTP into a payment channel
The x402 protocol revives the long-dormant HTTP 402 Payment Required status code as a real payment handshake. When an agent sends a request to a paid endpoint, the server responds with a 402 status and a JSON body containing payment terms: the price, the accepted currency (USDC), the destination address, and the settlement chain.
The agent's wallet reads those terms, signs a USDC transfer matching the amount, and retries the original request with an X-Payment header that contains the signed transaction. The server verifies the payment, settles it on-chain, and returns the API response. The entire flow completes in a single additional round-trip, with no OAuth, no redirect, and no invoice. For a full technical walkthrough of the status codes and headers involved, see the x402 explainer at /learn/what-is-x402.
Because the negotiation is embedded in HTTP itself, any HTTP client can be extended to support it. This matters for agent frameworks: adding x402 support to an agent's HTTP layer means every API the agent discovers becomes payable without per-vendor integration code.
Wallet-based vs. managed-credit approaches
There are two broad architectures for agent payments. In a wallet-based approach, the agent (or its runtime) holds a cryptographic wallet funded with stablecoins. The agent signs transactions directly, and settlement happens on-chain. This gives the developer full custody and transparent accounting per call.
In a managed-credit approach, a third-party platform holds a balance and issues API calls on the agent's behalf, deducting from a prepaid credit pool. This simplifies onboarding but centralizes trust: the developer depends on the platform for accounting, rate limits, and fund availability.
AgentCash follows the wallet-based model. Developers run npx agentcash to create a wallet, fund it with USDC on Base, Solana, or Tempo, and the agent pays providers directly via x402. The developer sets spending caps; the agent operates within them. There is no intermediary holding funds on the agent's behalf.
What AgentCash indexes today
AgentCash currently indexes 1 payment-protected origin spanning 1 API category, with 30 priced endpoints available across that origin. The median observed price per call is $0.028, and the range spans from $0.002 to $0.440 per call, as of April 2026. These numbers reflect the early state of the x402 ecosystem; as more API providers adopt 402-based pricing, the index will grow.
Developers interact with AgentCash through the CLI and through an MCP server that plugs directly into coding agents like Claude, Cursor, and Claude-Code. The MCP server intercepts 402 responses, handles wallet signing, and retries the request, so the agent's application code never has to implement payment logic itself.
Getting started: from zero to a paying agent in minutes
Install the AgentCash CLI with npx agentcash. This creates a local wallet and provides a funding address. Send USDC on Base, Solana, or Tempo to that address. Once the balance is confirmed, every x402-protected API in the index is callable without additional signup.
To integrate with a coding agent, install the AgentCash MCP server into your agent's configuration. The MCP server handles the full x402 handshake transparently. Your agent issues normal HTTP requests; when a 402 response arrives, the MCP server negotiates and pays. From the agent's perspective, it simply gets data back.
Set spending caps per session or per task to bound autonomous spend. The wallet will reject any payment that would exceed the configured limit, so a runaway loop cannot drain the balance.
Tradeoffs and limitations to consider
On-chain settlement adds latency compared to a cached API key. The x402 round-trip typically adds one extra HTTP exchange per paid call. For latency-critical paths, this overhead may matter; for most agent workloads that call APIs in sequence, it is negligible.
Stablecoin wallets require the developer to hold USDC, which means exposure to stablecoin-specific risks (issuer solvency, regulatory changes). This is a different risk profile than a credit card, and developers should evaluate it accordingly.
The x402 ecosystem is still early. Not every API supports 402 responses. Agents that need to call non-x402 APIs will still need traditional API keys for those services. AgentCash handles the x402 portion; legacy integrations remain the developer's responsibility.
Frequently asked questions
Do payments for AI agents require the agent to hold its own private key?
In wallet-based systems like AgentCash, yes. The agent's runtime holds a wallet created via npx agentcash, and that wallet signs USDC transactions. The private key stays local to the developer's machine or server. Managed-credit platforms avoid this by holding funds centrally, but at the cost of custody control.
Which blockchains does AgentCash settle payments on?
AgentCash settles on Base, Solana, and Tempo. All three use USDC as the payment currency. The specific chain is determined by the payment terms the API server includes in its 402 response.
Can I set a maximum spend limit so my agent does not drain my balance?
Yes. AgentCash supports spending caps configured per session or per task. The wallet rejects any payment that would exceed the cap, preventing runaway spending from loops or unexpected API costs.
How does the x402 handshake work when my agent hits a paid endpoint?
The server returns HTTP 402 with payment terms (price, currency, chain, destination). The agent's wallet signs a matching USDC transfer and retries the request with an X-Payment header. The server verifies and settles the payment, then returns the API response. It adds one extra HTTP round-trip.
Do I need to sign up with each API provider separately?
No. With AgentCash, you fund one USDC balance and call any x402-protected endpoint without per-vendor registration. The x402 protocol handles payment negotiation at the HTTP layer, so no API keys or accounts are needed for participating providers.
What happens if the agent calls an API that does not support x402?
AgentCash only handles x402-compatible endpoints. For APIs that still require traditional API keys or subscriptions, you need to provision access separately. The two models can coexist in the same agent; non-402 calls proceed normally.
How much does a typical API call cost through AgentCash?
The median observed price is $0.028 per call, with a range of $0.002 to $0.440 across the 30 currently indexed endpoints. Prices are set by the API provider in their 402 response, not by AgentCash.
How do I install the AgentCash MCP server into my coding agent?
After running npx agentcash to set up your wallet, follow the CLI prompts to configure the MCP server for your agent (Claude, Cursor, or Claude-Code). The MCP server intercepts 402 responses and handles wallet signing automatically, so your agent code does not need payment logic.
Related
An ai agent wallet lets autonomous agents pay for APIs using one USDC balance. Learn self-custody vs managed wallets, spending caps, and setup.
Pay per call API pricing lets AI agents pay only for the requests they make. Learn how per-call billing compares to subscriptions and how to get started.
x402 revives HTTP 402 Payment Required as a real stablecoin payment protocol. Learn the handshake, MCP integration, and how AI agents use it.
Get started with AgentCash
One balance, USDC on Base · Solana · Tempo. Call any payment-protected API from your agent — no API keys.
This page is compiled from live OpenAPI specs published by each API provider. Content last reviewed Apr 7, 2026 by the AgentCash team. How we build these pages.