Concepts and protocols
How can an AI agent pay for an API?
Prepaid keys, pay-per-call protocols like x402 and MPP, or paying a provider directly from a controlled wallet. Trade-offs, and what to limit in each.
Three common ways: you buy credits and give the agent an API key, the API charges per call through a machine payment protocol such as x402 or MPP, or the agent pays the provider from a wallet you control through a policy layer. Each needs a limit somewhere.
Why is this harder than it sounds?
Most APIs were sold to people: sign up, choose a plan, add a card. An agent can use a key you set up, but it can't easily sign up to a new service mid-task, and a key with a card behind it often has no per-call limit the agent can't exceed. Pay-per-call protocols remove the sign-up but move the spending decision into the agent's own client. The right choice depends on whether the provider supports a protocol, how often the agent needs new providers, and where you want the limit to live.
How do you do it?
- Prepaid credits and a key. Simple, and the provider's balance is your limit. Works only with providers you set up in advance.
- Pay per call with x402. If the API supports it, the agent's client pays the 402 challenge on each call. The client needs a key that can sign, so the limit has to be in that client or wallet.
- Pay per call with MPP. Stripe describes the Machine Payments Protocol as able to take card and stablecoin payments, with cards via Shared Payment Tokens that carry usage and expiry limits.
- Pay the provider directly. The agent requests a payment to the provider's address for credits or a top-up, through a service that applies limits and approvals.
- Whichever you choose, cap it. Set a per-payment and daily maximum outside the model, and a list of providers the agent may pay.
What it does not mean
- A key with no spending cap is not 'free to use'. The bill arrives later.
- Pay-per-call doesn't mean cheaper. It means no account; the price is whatever the server asks.
- Payment proof is not delivery. An agent that has paid still needs the provider to credit it.
Common questions
Can one agent use more than one method?
Yes. Many agents use prepaid keys for regular services and a wallet-based tool for occasional ones.
Which networks do x402 and MPP use?
Stripe lists x402 for USDC on Base and MPP on Tempo and Solana. The x402 spec itself supports more networks through its schemes.
Where does Veyra fit?
Veyra fits the third route. Its create_payment tool description tells the agent to use it whenever completing a task requires paying someone, such as a paywalled API, a dataset or a top-up, within your limits. Once a payment is confirmed on Base, get_payment returns tx_ref and a Basescan link to show the provider. Veyra doesn't speak x402 or MPP, so it suits providers that accept a USDC transfer to an address, not ones that only accept a protocol challenge.
Sources
Terms on this page
- HTTP 402 Payment Required402 Payment Required is an HTTP response status code that RFC 9110 lists as 'reserved for future use', meaning HTTP itself defines no standard behaviour for it.
- Shared Payment Token (SPT)A Shared Payment Token (SPT) is a Stripe credential that grants an agent or seller scoped use of a customer's payment method, such as a card, with usage and expiration limits.
- Payment intentA payment intent is an object representing a payment that has been requested but not necessarily completed, which moves through defined states such as awaiting approval, submitted, confirmed or cancelled.
This page explains how agent payments and the related technology work. It is not financial, investment, legal or tax advice. Protocols and provider features change; check the linked official sources before relying on a detail.