Agentic payments with MPP
With the Machine Payments Protocol (MPP), AI agents can buy a prepaid Apify API token and pay with stablecoins on Tempo or Solana, without an Apify account.
Agentic payments are experimental and may change as payment protocols evolve.
How MPP works
Buying and using a token takes four steps:
- Set up a wallet on Tempo or Solana and fund it with a supported stablecoin.
- Request a prepaid token from Apify AGI. Your MPP client pays for it from the wallet.
- Apify AGI verifies the payment and returns a prepaid Apify API token.
- Use that token as your Apify API token until its balance runs out or it expires.
MPP is a protocol for paying for HTTP resources from code. A server answers an unpaid request with HTTP 402 Payment Required and one or more payment challenges. The client pays one challenge and repeats the request with proof of payment.
Apify AGI (Agent General Interface) sells the token and handles the payment. It uses the charge intent, a one-time payment. You pay once upfront for a prepaid token, then use that token to run Actors until its balance runs out. For the full, always-current instructions, read Apify AGI's AGENTS.md.
Supported networks and currencies
Apify AGI offers one challenge per network and currency, in the order below. Pay whichever one your wallet holds funds for.
| Network | Currency |
|---|---|
Tempo mainnet (chain ID 4217) | USDC.e |
Tempo mainnet (chain ID 4217) | pathUSD |
| Solana mainnet | USDC |
| Solana mainnet | USDT |
Your MPP client reads each token address or mint from the 402 challenge, so you never enter one by hand. Each currency links to its issuer or block explorer entry, where you can check the address yourself.
USDC.e is the Tempo token for bridged USDC. Its on-chain name is Bridged USDC (Stargate).
Prerequisites
- An MPP client for the network you pay on:
- On Tempo, the mppx CLI.
- On Solana, mppx with
@solana/mppand@solana/kit, or the pay.sh CLI.
- A wallet holding the amount you want to buy, at least $1, in one of the supported currencies.
- Funds in the same wallet for the network fee, because Apify AGI doesn't sponsor fees. On Solana, that's a small amount of SOL.
Request a prepaid token
Buy a token with a GET or POST request to this endpoint:
https://agi.apify.com/protocols/mpp/prepaid-tokens?amount=5¤cy=usd
amount- A USD amount, such as5or1.50. Use at most two decimals. If it's missing or invalid, the challenge falls back to $1. Requests below $1 are rejected.currency- A currency code. The only accepted value isusd.
Buying a token takes two requests, and MPP clients make both for you. The first carries no payment, and Apify AGI answers with 402 and one challenge per supported currency. The client pays one challenge and repeats the request with an Authorization: Payment header. Apify AGI verifies the payment and answers with 201 and the token, its balance, and its expiry time:
{"token":"apify_api_...","remainingBalanceUsd":5,"expiresAt":"..."}
If you write your own MPP client, the 402 response carries one WWW-Authenticate: Payment header per challenge, and its body repeats the challenges as JSON.
Choose push or pull mode
Apify AGI accepts the charge intent in two modes. Your client picks the mode when it builds the payment credential.
- In push mode, your client broadcasts the transfer itself and sends the transaction hash (Tempo) or signature (Solana). Apify AGI verifies the transfer on-chain and mints the token. It ignores the
amountin the request, and the token gets the amount of the challenge you paid. Use push mode when your client can broadcast. - In pull mode, your client signs the transfer but doesn't broadcast it. Apify AGI compares the signed amount with
amountin the request, then broadcasts the transaction. If they differ, it returns400 amount-mismatchand broadcasts nothing. Use pull mode when your client can sign but can't broadcast.
Pay on Tempo
Pay with USDC.e or pathUSD on Tempo mainnet using the mppx CLI. It reads the challenges, pays a Tempo one, and repeats the request for you. Install the CLI, create an account, and fund its address with USDC.e or pathUSD on Tempo. Then request the token:
npm i -g mppx
mppx account create
mppx account view # print the address to fund
mppx 'https://agi.apify.com/protocols/mpp/prepaid-tokens?amount=5¤cy=usd' # buy a $5 token
The CLI keeps its account in the operating system keychain, so on headless Linux without a keychain service, use the mppx client library with a viem account instead.
Pay on Solana
Pay with USDC or USDT on Solana mainnet, and keep a small amount of SOL in the same wallet for the network fee. Install the client packages with npm install mppx @solana/mpp @solana/kit.
Pass a @solana/kit TransactionSigner to solana.charge, and set broadcast: true for push mode or broadcast: false for pull mode. The client pays the first challenge it can, in server order, so a wallet holding only USDT needs an orderChallenges callback passed to Mppx.create that puts USDT first.
import { createKeyPairSignerFromBytes } from '@solana/kit';
import { solana } from '@solana/mpp/client';
import { Mppx } from 'mppx/client';
// A 64-byte keypair as a JSON array, the format of a Solana CLI keypair file
const keypair = new Uint8Array(JSON.parse(process.env.SOLANA_KEYPAIR));
const signer = await createKeyPairSignerFromBytes(keypair);
const mppx = Mppx.create({
methods: [solana.charge({ signer, broadcast: true })], // false for pull
polyfill: false, // keep the global fetch untouched
});
const response = await mppx.fetch('https://agi.apify.com/protocols/mpp/prepaid-tokens?amount=5¤cy=usd');
console.log(response.status, await response.json());
You can also pay with pay.sh, the Solana Foundation's payments CLI, which signs a pull credential and repeats the request for you:
npm install -g @solana/pay
pay setup # set up a wallet
pay whoami # print the address to fund
pay --mainnet --mpp curl 'https://agi.apify.com/protocols/mpp/prepaid-tokens?amount=5¤cy=usd'
Use the prepaid token
Send the token as a bearer token to the Apify API. It acts as an API token until its balance runs out or it expires. Treat it like a secret, and don't print it or store it where others can read it.
It's the same kind of prepaid token the x402 flow returns. The token also works as the bearer credential for the Apify MCP server. Pass it in the Authorization header instead of signing in with OAuth. Check the remaining balance and expiry time at any time:
curl -s "https://agi.apify.com/prepaid-tokens/balance" -H "Authorization: Bearer $TOKEN"
# → {"remainingBalanceUsd":5,"expiresAt":"..."}
Run an Actor
Export the token, then find an Actor and run it:
export TOKEN="apify_api_..." # the token from the previous step
When using the API, replace the / in the Actor name with ~ (for example, apify/instagram-post-scraper becomes apify~instagram-post-scraper).
# Find an Actor in the store
curl -s "https://api.apify.com/v2/store?search=instagram&limit=5"
# Run an Actor and get its dataset items in one call
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"username": ["natgeo"], "resultsLimit": 3}' \
"https://api.apify.com/v2/actors/apify~instagram-post-scraper/run-sync-get-dataset-items"
# → JSON array with the scraped Instagram posts
To review what an Actor does and which input it accepts, fetch its Markdown documentation at https://apify.com/<username>/<actor-name>.md.
Supported Actors
A prepaid token works like a regular API token, so it runs any Actor that uses limited permissions, whatever its pricing model. Actors that need full permissions return an error, because a prepaid account can't approve them. The pay-per-event eligibility rules for agentic payments apply only to payments made per request, such as with Skyfire.
Token pricing and limits
- The smallest token you can buy is $1.
- The token balance is an absolute spending cap. Every Actor run draws from it until the balance runs out.
- The token expires 14 days after you buy it, and
expiresAtgives the exact time. Any unused balance is non-refundable. - A prepaid account also has usage limits, such as 1,000 compute units.
- Your wallet pays the network fee in both push and pull mode.
Next steps
- Read the MPP documentation for details of the protocol.
- Browse Apify Store for Actors to run.
- To pay with the alternative x402 protocol instead, follow the x402 integration guide.