Useful for
- Monetizing an existing Express, FastAPI, MCP, or A2A agent without building billing yourself.
- Charging per request (fixed or dynamic credits) with metering and settlement handled for you.
- Generating the registration script + middleware + a test in one pass, so you go from unpaid to paid in minutes.
Try it yourself
Run this in your project with a coding agent that can read and edit your files:Swap the framework line for your stack — guides exist for Express, FastAPI, Strands, and generic HTTP.
How it works
Register an agent and a plan
Publish the service and price it. The SDK helpers build the on-chain price/credits config for you:See Register a plan & agent for the full options (fiat pricing, time-based and pay-as-you-go plans).
- TypeScript
- Python
Gate your routes with middleware
Add the payment middleware and list the routes to protect with their credit cost. Everything not listed stays public:The middleware returns
- Express (TypeScript)
- FastAPI (Python)
402 with a payment-required challenge when the token is missing, verifies it when present, runs your handler, then settles (burns credits) and returns the receipt in payment-response.Related
Register a plan & agent
Publish and price the service you’re protecting.
Nevermined x402
The protocol behind the paywall: schemes, headers, verify/settle.
Check revenue
Once you’re charging, track what you earn.
Buy access
See the buyer side that mints the token your paywall checks.