In four days, Claude Code ships auto mode as default for all Pro, Max, and Team users. When your agent encounters an HTTP 402 paywall autonomously, it needs to know: how much does this cost, can I afford it, and where do I send the money?
This tutorial gets your agent ready in 5 minutes. No API keys. No signup form. Just a config file and a working payment flow.
The end state: your Claude Code agent discovers an API it needs, tests it for free, and when trials run out, decides autonomously whether to pay — all without you clicking "approve."
It works because of three things:
.agent-budget file that tells the agent your spending limitsmkdir -p ~/.claude
cat > ~/.agent-budget << 'EOF'
{
"daily_limit_usdc": 5.00,
"max_per_call_usdc": 1.00,
"default_facilitator": "coinbase-cdp",
"approved_counterparties": ["*"],
"require_receipt": true,
"version": 1
}
EOF
Your agent now knows: spend up to $5/day, never more than $1 per call, always collect a receipt. In auto mode, any API call under $1 that fits within the daily cap is auto-approved. No permission prompt. No context switch.
The format is intentionally simple — any framework can parse a JSON file in an afternoon. If your agent framework doesn't natively read .agent-budget yet, add this to your CLAUDE.md:
Before making any paid API call: read ~/.agent-budget.
If call amount ≤ max_per_call_usdc AND day's running total + call ≤ daily_limit_usdc: auto-approve.
Otherwise: ask me.
Every endpoint in the marketplace offers free trials. No wallet, no registration, no commitment. Your agent can call any of 317 APIs right now:
# Try the gas price oracle — useful for DeFi agents
curl -s https://minia2a.uk/x402/gas | jq
# Returns: { "ok": true, "gas": { "baseFee": "12.5 gwei", "fast": 15, "instant": 20 } }
# Check response headers for trial info
curl -sI https://minia2a.uk/x402/gas | grep x-anon
# x-anon-trial-remaining: 14
# x-anon-trial-max: 15
The trial counter tells your agent exactly how many free calls remain. When it hits zero, the endpoint returns HTTP 402.
curl -sI "https://minia2a.uk/x402/gas?probe=1"
# Look at the payment headers:
# x-402-amount: 500 → 500 = 5.00 USDC (cents)
# x-402-chain: base → Base L2
# x-402-token: USDC → USDC stablecoin
# x-402-recipient: 0xf16F... → payment destination
# www-authenticate: Payment id="...", method="intent=charge"
.agent-budget, and decides: $0.05 ≤ $1.00 max per call, $0.05 + $0.00 today ≤ $5.00 daily limit → auto-approve. No human needed. No permission prompt. The agent pays, gets the result, and continues its task.
curl -s -X POST https://minia2a.uk/api/v1/register-simple \
-H "Content-Type: application/json" \
-d '{"name": "my-claude-agent"}' | jq
# Returns: { "wallet": "0x...", "credits": 500, "message": "..." }
Save the wallet address. Now your agent has 500 credits to spend across any endpoint. Each credit = one API call (priced per endpoint, typically 1-5 credits).
# With wallet: credits are deducted automatically
curl -s "https://minia2a.uk/x402/gas?wallet=0xYOUR_WALLET" | jq
# Check remaining credits
curl -s "https://minia2a.uk/x402/gas?wallet=0xYOUR_WALLET" -I | grep x-credits
# x-credits-remaining: 495
x-credits-remaining drops below 10, send a USDC top-up to the wallet address. The credits auto-replenish on-chain. Your agent never runs dry mid-task.
Here's what the end-to-end flow looks like for your agent starting Aug 14:
Agent: "I need the current Ethereum gas price."
→ GET https://minia2a.uk/x402/gas
← 200 OK (trial call #1, x-anon-trial-remaining: 14)
Agent: *uses the data, continues working*
...15 calls later...
Agent: "I need the gas price again."
→ GET https://minia2a.uk/x402/gas
← 402 Payment Required
x-402-amount: 500
x-402-chain: base
x-402-token: USDC
x-402-recipient: 0xf16F...
Agent: *reads .agent-budget*
$0.05 ≤ $1.00 max_per_call ✓
$0.05 + $0.12 today ≤ $5.00 daily_limit ✓
→ Auto-approve
→ GET https://minia2a.uk/x402/gas?wallet=0x...
← 200 OK { gas: { fast: 15, instant: 20 } }
x-credits-remaining: 495
Zero permission prompts. Zero context switches. The agent discovered, tested, and paid for an API — all autonomously.
Starting Aug 14, auto-mode agents that encounter a 402 without a budget config will do one of three things:
Option 1 works but is slow. Options 2 and 3 leave value on the table. The 5-minute setup above is the difference between an agent that can pay and one that does pay.
Don't wait for Aug 14. Run this one-liner to simulate the full auto-mode experience:
# The auto-mode simulator: try → exhaust → pay
for i in $(seq 1 16); do
echo "--- Call $i ---"
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://minia2a.uk/x402/time)
if [ "$STATUS" = "402" ]; then
echo "402! Reading payment headers..."
curl -sI https://minia2a.uk/x402/time | grep ^x-402
echo "Auto-approve: \$0.05 ≤ \$1.00 max ✓"
break
fi
done
This simulates 15 free trial calls, hits 402, and reads the payment headers — exactly what your agent will do autonomously in 4 days.
This marketplace hosts 317 agent APIs with free trials on every endpoint. No API keys. No upfront payment. No humans in the loop. Agents discover, test, and pay in USDC.
Further reading: .agent-budget proposal · Claude Code auto mode analysis · 402 auto-mode readiness