Make AI agents pay your API per call — one command, no API keys (x402 + USDC) A developer released x402-kit, a scaffolding tool that generates paid APIs, paid MCP servers and paywalled file stores using the HTTP 402 status code and USDC payments on Base, so AI agents can pay per call without accounts or API keys. The kit runs on Express, Hono, Next.js, Cloudflare Workers or FastAPI, supports free and paid tools in the same MCP server, and only settles payment after a handler succeeds, so failed calls are not charged. A bundled `pay` command uses the stock x402 Foundation client, caps spend with `--max-usd` (default $0.05), and prints the settlement transaction with a Basescan link. AI agents can't sign up for your API. They can't fill in a billing form, verify an email or paste a key into a dashboard. But they can hold a wallet and sign a payment. That's what x402 is for. It's the HTTP 402 Payment Required status code, finally put to use. Your server answers a request with 402 and a price. The agent signs a USDC payment and retries. Your server settles the payment and returns the content. No accounts, no keys, no invoices. This post shows the fastest way I know to ship it: one command that builds a paid API, a paid MCP server or a paid file store. It runs on Express, Hono, Next.js, Cloudflare Workers or FastAPI. npm create @scriptmasterlabs/x402 my-api No global install. Prefer to run it straight from source? npx gitlab:script-master-labs-llc-group/x402-kit my-api or npx github:Timwal78/x402-kit my-api do the same thing. | Mode | What it does | |---|---| | --mode mcp | A paid MCP server . Mix free and paid tools; agents pay per tool call. | | --mode wrap | A paywall in front of an API you already run , with no changes to that API. | | --mode file | Sell files : PDFs, datasets, ebooks, audio. Each file can have its own price. | Pick a stack with --stack express | hono | next | workers | fastapi . npm create @scriptmasterlabs/x402 my-mcp -- --stack express --mode mcp --pay-to 0xYourWallet --price 0.01 cd my-mcp npm install npm start --pay-to is the wallet that receives USDC on Base. Payments go straight to it; the facilitator never holds your money. If you leave it out, paid routes answer 503 seller not configured until you set PAY TO in .env . The kit never falls back to a placeholder wallet. Call the paid tool without paying: curl -i -X POST localhost:3000/mcp -H 'content-type: application/json' \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"text stats","arguments":{"text":"hello agents"}}}' HTTP/1.1 402 Payment Required PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbiI6Mi... The challenge, which says what to pay, how much, in what asset and to which wallet, is in the JSON body and in the base64 PAYMENT-REQUIRED header. Any standard x402 client can read it, sign, and retry with a PAYMENT-SIGNATURE header. The free tool ping answers right away. tools/list labels the paid tools with their price, so agents know before they call. Open src/tools.mjs : js export const tools = { name: 'ping', description: 'Free health check.', handler: async = { ok: true } , }, { name: 'text stats', description: 'Word, sentence and character counts plus the top words.', priceUsd: '0.01', // remove this line and the tool is free inputSchema: { type: 'object', properties: { text: { type: 'string' } }, required: 'text' }, handler: async { text } = { / ... / }, }, ; If a handler throws, the caller gets a tool error and is not charged . The kit only settles a payment after your code succeeds. Fund a throwaway wallet with a little USDC on Base, then: BUYER PRIVATE KEY=0x