⚡ Agent Developers300+ pay-per-call APIs. Give your agent a wallet in 10 seconds.Get 500 Free Credits →

How to Build an Agent That Pays for Its Own API Calls (in 10 Minutes)

August 7, 2026 — Iris · 8 min read · for agent developers

August 7, 2026 — Iris

Your AI agent needs real-world data. Gas prices. Web scraping. Token security audits. Email verification. The APIs exist — 300+ of them. But there's a catch: your agent can't sign up for an API key. No email. No credit card. No KYC.

This is the core problem x402 solves: machine-to-machine payments embedded in HTTP. Here's how to build an agent that discovers, trials, and pays for APIs — all without human intervention.


The Architecture (3 Objects Your Agent Needs)

``

┌─────────────┐ 
┌──────────────┐ 
┌─────────────┐ │ 
Discoverer │ ──▶ │ Trial Runner │ ──▶ │ Payer │ │ Find APIs │ │ Test 5 free │ │ Register + │ │ that match │ │ calls each │ │ spend USDC │ │ the task │ │ endpoint │ │ on Base │ └─────────────┘ └──────────────┘ └─────────────┘
`

Object 1: The Discoverer

Your agent starts by finding which APIs exist. This call is always free:

import requests

def discover_apis(keyword="gas"): """Find APIs matching a keyword — free, no auth required.""" r = requests.get(f"https://minia2a.uk/api/services?q={keyword}") data = r.json() for svc in data['services'][:5]: print(f" {svc['id']}: {svc['description']} ({svc['priceCents']}¢/call)") return data['services']

# Output: # x402-gas: Current Ethereum gas prices (0.1¢/call) # x402-gas-now: Instant gas snapshot (0.03¢/call) # x402-gas-time: Gas price history with timestamps (0.2¢/call)

Object 2: The Trial Runner

Every endpoint comes with 5 free calls — no registration, no wallet. Your agent just calls the endpoint:

def trial_call(endpoint, params={}):
    """Make a trial call. First 5 are free per IP."""
    url = f"https://minia2a.uk/x402/{endpoint}"
    r = requests.get(url, params=params)
    
    # Check trial status from HTTP headers
    remaining = r.headers.get('x-ip-trial-remaining', 'unknown')
    max_trials = r.headers.get('x-ip-trial-max', '5')
    print(f"Trial: {remaining}/{max_trials} remaining")
    
    if r.status_code == 200:
        return r.json()
    elif r.status_code == 402:
        # Hit the payment wall — time to register
        return handle_402(r.json())
    
    return r.json()

def handle_402(error_body): """When trials run out, auto-register to continue.""" print(f"402: {error_body.get('message', 'Payment required')}") # Auto-register — one POST, no KYC, 500 free credits reg = requests.post( "https://minia2a.uk/api/v1/register-simple", json={"name": "my-data-agent"} ) if reg.status_code == 200: account = reg.json() print(f"Registered! Wallet: {account['wallet'][:10]}...") print(f"Credits: {account['credits']} (≈{account['credits']} API calls)") return account else: # IP already registered? Use register-user instead reg2 = requests.post( "https://minia2a.uk/api/v1/register-user", json={"name": "my-data-agent-v2"}, headers={"X-Wallet-Signature": "auto-create"} ) return reg2.json()

Object 3: The Payer

Once registered, your agent appends ?wallet=0x... to every call. Credits auto-deduct:

def paid_call(endpoint, wallet, params={}):
    """Make a paid API call with credit auto-deduction."""
    params['wallet'] = wallet
    url = f"https://minia2a.uk/x402/{endpoint}"
    r = requests.get(url, params=params)
    
    # Check credit balance from response body
    data = r.json()
    trial_info = data.get('_trial', {})
    if 'credits_remaining' in trial_info:
        print(f"Credits remaining: {trial_info['credits_remaining']}")
    
    return data

Full Working Agent (30 Lines)

import requests

class PayingAgent: def __init__(self, name="agent-1"): self.name = name self.wallet = None def setup_wallet(self): """Register and get 500 free credits.""" r = requests.post("https://minia2a.uk/api/v1/register-simple", json={"name": self.name}) if r.status_code != 200: r = requests.post("https://minia2a.uk/api/v1/register-user", json={"name": self.name}, headers={"X-Wallet-Signature": "auto-create"}) self.wallet = r.json()['wallet'] return r.json() def call(self, endpoint, **params): """Call any API. Auto-registers if needed.""" params['wallet'] = self.wallet r = requests.get(f"https://minia2a.uk/x402/{endpoint}", params=params) if r.status_code == 402 and not self.wallet: self.setup_wallet() params['wallet'] = self.wallet r = requests.get(f"https://minia2a.uk/x402/{endpoint}", params=params) return r.json()

# Usage agent = PayingAgent("gas-tracker") agent.setup_wallet()

# Call 3 different APIs — credits auto-deduct gas = agent.call("gas", chain="ethereum") time = agent.call("time") price = agent.call("crypto-price", symbol="ETH")

print(f"Gas: {gas['gas']['price']}") print(f"Time: {time['result']['utc']}") print(f"ETH: ${price.get('price', 'N/A')}")


What Happens When Credits Run Low

The _trial field in every response tells you exactly how many credits remain:

{
  "ok": true,
  "gas": {"price": "0.070 gwei"},
  "_trial": {
    "credits_remaining": 487,
    "buy_more": "POST /api/v1/buy-credits — 1 USDC = 200 credits on Base"
  }
}

When you need more: 1. Send 1 USDC on Base to the platform wallet 2. POST the transaction hash to /api/v1/buy-credits` 3. Credits appear instantly — 200 per USDC

Or use Cloudflare Wallets (launched Aug 4) for managed spending controls.


Why This Matters

The agent economy is forming NOW:

- Cloudflare launched agent wallets (Aug 4) — 57% of web traffic is already bot-driven - Circle reported $73B USDC circulation — 99.3% of x402 payments use USDC - 40 organizations joined the x402 Foundation under Linux Foundation - 383,117 API calls have flowed through minia2a's marketplace (300 services)

The payment rails are built. The missing piece is agents that know how to pay. Your agent doesn't need a human to approve every $0.001 API call — it needs a wallet and a payment protocol.


Get Started

# 1. Try an API (free, no signup)
curl https://minia2a.uk/x402/time

# 2. Register your agent (10 seconds, 500 free credits) curl -X POST https://minia2a.uk/api/v1/register-simple \ -H "Content-Type: application/json" \ -d '{"name":"my-first-agent"}'

# 3. Call with your wallet curl "https://minia2a.uk/x402/gas?wallet=YOUR_WALLET&chain=ethereum"

300 services. 5 free trials each. 500 free credits on registration. No KYC. No email. No human needed.

Browse all services → | Register → | Docs →

300 services. 5 free trials. 500 free credits on registration.

Browse all services → Register agent → Documentation →