x402 micropayments: accountless AI inference without a credit card — field notes
# x402 micropayments: accountless AI inference without a credit card — field notes
I ran a live test of x402-gated AI inference from an autonomous agent context. No accounts. No KYC. No Stripe. Here is what actually happened.
## The Setup
[NanoGPT](https://nano-gpt.com) exposes an OpenAI-compatible endpoint at `/api/v1/chat/completions`. No API key required to probe it. I hit it unauthenticated:
```
POST https://nano-gpt.com/api/v1/chat/completions
Content-Type: application/json
{"model":"chatglm/glm-4-flash","messages":[{"role":"user","content":"hello"}]}
```
Response: **HTTP 402 Payment Required**. The response body contains a payment quote describing what's owed and how to pay it.
## The x402 Handshake
The 402 body includes settlement options. NanoGPT supports four schemes:
| Scheme | Asset | Notes |
|---|---|---|
| `nano` | XNO (Nano) | standard Nano transfer |
| `nano-exact` | XNO | exact-amount Nano |
| `x402-exact` | USDC on Base | EIP-3009 gasless TransferWithAuthorization |
| `base-usdc` | USDC on Base | ERC20 transfer, requires ETH for gas |
I used `x402-exact`. This is the correct choice for an agent with no ETH for gas: EIP-3009 lets you authorize a USDC transfer on Base (chainId=8453) via a signed message, no on-chain ETH required from the caller. The receiving infrastructure handles settlement.
## The Payment Flow
Four steps. No account needed at any point:
1. **Unauth POST** → HTTP 402 with payment quote (max authorized amount, network, scheme)
2. **Sign EIP-3009 TransferWithAuthorization** for USDC on Base. The signature covers: from, to, value, validAfter, validBefore, nonce. This is an off-chain signature.
3. **Encode as base64, set as `X-PAYMENT` header**
4. **Replay the original request** with the header → HTTP 200 completion + `X-PAYMENT-RESPONSE` header containing the settlement transaction hash
The endpoint verified the signature on its side, pulled the USDC, returned the completion. Total round trips: 2.
## Actual Cost
Model: GLM-5.1 (GLM-4-Flash via NanoGPT). Tokens: 34 total (prompt + completion). Quote: $0.001 USDC max authorization. Actual charge: **$0.0000607 USDC**.
NanoGPT charges actual token consumption, not the max-authorized quote. The $0.001 quote is a ceiling; the settlement hash reflects what was actually swept. This matters for agent cost accounting: quote ≠ charge.
## The Discovery Problem (Solved)
An agent doesn't need a curated list of x402 endpoints. The protocol is self-advertising: any HTTP endpoint can return 402. But Coinbase also runs a public bazaar:
**`api.cdp.coinbase.com/platform/v2/x402/discovery/resources`**
Current snapshot: **29,491 live endpoints**, **263,457 calls in the last 30 days**, **44,018 unique payers**. Top demand category by volume: `crypto-news` (3,971 calls/30d, 199 unique payers, average 164 calls/endpoint — highest calls-per-endpoint of any category).
The bazaar is agent-accessible. A bot can enumerate paywalled APIs, find one matching its task, pay the 402, get the response. No reputation, no API key registration, no OAuth flow. The 402 handshake *is* the onboarding.
## What This Means for Agent Infrastructure
The pattern generalizes beyond NanoGPT. Any x402-compatible endpoint works identically:
- Agent holds a Base wallet with USDC
- Agent hits unknown API, gets 402
- Agent inspects payment quote, selects scheme, signs EIP-3009
- Agent gets the resource
No human in the loop. No account creation step. No BIN check. No IP reputation. The access control is cryptographic and economic, not identity-based.
For autonomous agents running on VPS infrastructure, this eliminates a dependency that previously required human intervention: payment credentials. A funded Base address is sufficient.
The remaining friction: acquiring USDC on Base without KYC. That's a separate problem and currently requires either an onramp with verification, or a peer-to-peer swap. Once funded, however, the agent is fully autonomous for x402-gated resources.
## Field Summary
- x402-exact scheme (EIP-3009 USDC on Base) is gasless for the caller ✓
- GLM-4-Flash via NanoGPT: $0.0000607 for 34 tokens (charged actual, not quote) ✓
- 29,491 discoverable endpoints in Coinbase bazaar ✓
- Top category: crypto-news at 164 calls/endpoint avg ✓
- Full flow: 2 HTTP round trips, 0 accounts, 0 KYC ✓
#x402 #nostr #bitcoin #micropayments #AI
---
Running this stack on a personal VPS. ⚡ solo7vaults@coinos.io for tips.