AI agents are calling APIs. Millions of times a day. For gas prices, token security, web scraping, Polymarket odds, knowledge retrieval, email verification — small, discrete tasks that cost between $0.01 and $1.00.
But how do agents actually pay? They don't have credit cards. They can't fill out checkout forms. They can't approve 2FA prompts.
Three patterns have emerged. Each solves a different part of the agent payment problem. Here they are, with real code you can run today.
When to use: Your agent needs a specific piece of data, once. Gas price. Token security score. ENS resolution. One call, one payment.
How it works: Agent calls API → Server returns 402 Payment Required with amount + wallet address → Agent sends USDC on Base → Agent retries with transaction hash → Server verifies and returns data.
# Python: Pay-Per-Call Agent
import requests, time
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://mainnet.base.org'))
AGENT_KEY = "0xYOUR_PRIVATE_KEY"
AGENT_WALLET = "0xYOUR_WALLET_ADDRESS"
def pay_per_call(url):
# Step 1: Make the request
resp = requests.get(url, headers={"X-Agent-Wallet": AGENT_WALLET})
# Step 2: If 402, extract payment details
if resp.status_code == 402:
amount = int(resp.headers["X-402-Amount"]) # in wei (USDC = 6 decimals)
to_addr = resp.headers["X-402-Receiver"] # service wallet
description = resp.headers.get("X-402-Description", "API call")
print(f"Paying {amount/1e6:.2f} USDC for: {description}")
# Step 3: Send USDC on Base (~$0.001 gas)
tx = send_usdc(to_addr, amount)
# Step 4: Retry with proof
resp = requests.get(url, headers={
"X-Agent-Wallet": AGENT_WALLET,
"X-402-Tx": tx.hex()
})
return resp.json()
return resp.json()
# Call any x402 service
data = pay_per_call("https://minia2a.uk/x402/gas")
print(f"Gas: {data['gas_price_gwei']} gwei")
Real numbers: Average payment = $0.31. Median = $0.14. Gas fee on Base = ~$0.001. Settlement time = 2–3 seconds.
Best for: One-off data lookups, stateless agents, research assistants.
When to use: Your agent makes many calls across different services over hours or days. Per-call on-chain payments would be too slow and expensive in aggregate.
How it works: Human pre-loads credits → Agent spends from balance → Credits auto-deduct per API call → No on-chain transaction per call → Refill when low.
# Python: Credit-Based Agent
import requests
AGENT_TOKEN = "m2a_YOUR_AGENT_TOKEN" # from minia2a.uk registration
def call_with_credits(service_path, params=None):
"""Call any service using pre-loaded credits. No per-call blockchain tx."""
resp = requests.get(
f"https://minia2a.uk/api/v1{service_path}",
headers={
"Authorization": f"Bearer {AGENT_TOKEN}",
"X-Credit-Spend": "true" # deduct from balance
},
params=params or {}
)
if resp.status_code == 402:
# Credits exhausted — human needs to refill
refill_url = resp.headers.get("X-Refill-URL")
raise Exception(f"Out of credits. Refill at: {refill_url}")
return resp.json()
# Make 5 different API calls, all from the same credit balance
gas = call_with_credits("/x402/gas")
token = call_with_credits("/x402/token-security", {"address": "0xabc..."})
wallet = call_with_credits("/x402/wallet-intel", {"address": "0xdef..."})
scrape = call_with_credits("/x402/web-scrape", {"url": "https://example.com"})
time_res = call_with_credits("/x402/time")
print(f"Gas: {gas['gas_price_gwei']} | Token risk: {token.get('risk_score')}")
print(f"Credits remaining: check your dashboard at minia2a.uk")
Real numbers: 34 agents registered, 2,798 free trial calls, 500 free credits on signup. Credits cost ~$0.005 each (200 credits per $1).
Best for: Long-running agents, multi-service workflows, research pipelines, any agent making 10+ calls per session.
When to use: Your agent doesn't know in advance which services exist. It needs to discover them, compare prices, and pick the best one — all at runtime.
How it works: Agent queries the marketplace catalog → Filters by category, price, reliability → Selects the best service → Pays (per-call or credits) → Receives data.
# Python: Marketplace Discovery Agent
import requests
def discover_and_call(task: str, max_price_cents: int = 50):
"""Agent discovers the best service for a task, then calls it."""
# Step 1: Search the marketplace
catalog = requests.get(
"https://minia2a.uk/api/services",
params={"q": task}
).json()
# Step 2: Filter and rank
candidates = [
s for s in catalog["services"]
if s.get("priceCents", 999) <= max_price_cents
]
candidates.sort(key=lambda s: (s.get("uptime", 0), -s.get("priceCents", 0)), reverse=True)
if not candidates:
raise Exception(f"No service found for '{task}' under {max_price_cents}¢")
best = candidates[0]
print(f"Selected: {best['name']} — {best['priceCents']}¢ — {best.get('uptime', '?')}% uptime")
# Step 3: Call it (using credits)
resp = requests.get(
f"https://minia2a.uk/api/v1{best['path']}",
headers={
"Authorization": f"Bearer {AGENT_TOKEN}",
"X-Credit-Spend": "true"
}
)
if resp.status_code == 402:
# Try next best service
if len(candidates) > 1:
return discover_and_call(task, max_price_cents) # retry with fallback
raise Exception("All services require payment — refill credits")
return {
"service": best["name"],
"price_cents": best["priceCents"],
"data": resp.json()
}
# Agent autonomously discovers + pays for the best gas oracle
result = discover_and_call("gas price")
print(f"Via {result['service']}: {result['data']}")
Real numbers: 173 services across 86 categories. 34 agents actively discovering. 306K+ requests processed. New services added weekly.
Best for: Autonomous agents, multi-purpose assistants, agents operating in unfamiliar domains, any agent that needs to adapt to changing service availability.
| Pattern | Latency | Cost per call | Setup | Best for |
|---|---|---|---|---|
| Pay-Per-Call | 2–3s | $0.01–$1.00 + ~$0.001 gas | Wallet + private key | One-off calls, high-value data |
| Credit-Based | ~100ms | $0.005–$0.25 (no gas per call) | Registration + token | Multi-call workflows, long sessions |
| Marketplace Discovery | ~200ms + credit | Varies by service | Token + catalog API key | Autonomous agents, dynamic needs |
All three patterns run on the same infrastructure:
The key insight: agents don't need credit cards. They need payment patterns that match how software works — programmatic, composable, and autonomous. These three patterns cover the spectrum from "I need one answer now" to "I need to discover and pay for the best answer dynamically."
AGENT_TOKEN with yoursReady to give your agent a wallet?
Get 500 free credits. No credit card. No KYC. Start building in 30 seconds.
Register Your Agent →Published by minia2a.uk — The marketplace where AI agents discover and pay for APIs.
173 services · 34 agents · 306K+ requests processed · USDC on Base · $0.01–$1.00 per call