How we're bringing programmable payments to AI agents using the web's native payment protocol
The Problem: AI Agents Need to Get Paid
The AI revolution is here, and millions of agents are being built every day—coding assistants, research tools, medical advisors, financial analysts. But there's a fundamental problem: how do these agents get paid?
Traditional payment systems weren't designed for machine-to-machine commerce. They require human intervention, complex integrations, and assume a browser-based checkout flow. When an AI agent needs to pay another AI agent for a service, the options are limited:
- Stripe/PayPal: Designed for humans, requires redirects and card entry
- API Keys + Monthly Bills: No per-request pricing, no real-time access control
- Custom Solutions: Every developer builds their own broken payment system
What we need is a payment protocol that's native to HTTP—one that AI agents can understand and use automatically.
Enter x402: The Web's Native Payment Protocol
HTTP has always had a status code for payments: 402 Payment Required. It was reserved in 1999 but never standardized. Until now.
The x402 protocol finally gives meaning to that status code:
- Client requests a resource
- Server responds with 402 and payment requirements
- Client signs a payment authorization locally
- Server verifies and settles the payment
- Client gets access to the resource
No redirects. No checkout flows. No human intervention. Just HTTP.
Nevermined's Programmable Extension: nvm:erc4337
Standard x402 handles simple "pay X tokens for this request" flows. But AI agents need more:
- Subscription models: "This agent is on our enterprise plan"
- Credit systems: "Deduct 5 credits from my balance"
- Usage caps: "Don't let me spend more than $100 today"
- Delegated payments: "My company's smart account pays, not me personally"
That's why we built the nvm:erc4337 scheme—an extension that makes x402 programmable.
What Makes It Different?
How It Works
When a client calls a protected endpoint, they receive a 402 response with payment requirements:
{
"x402Version": 2,
"error": "Payment required to access resource",
"resource": {
"url": "/api/v1/agents/809184270231.../tasks",
"description": "AI agent task execution",
"mimeType": "application/json"
},
"accepts": [{
"scheme": "nvm:erc4337",
"network": "eip155:84532",
"planId": "44742763076047497640080230236781474129970992727896593861997347135613135571071",
"extra": {
"version": "1",
"agentId": "80918427023170428029540261117198154464497879145267720259488529685089104529015"
}
}],
"extensions": {}
}
The resource object describes what's being protected, accepts lists the payment schemes the server supports, and extensions allows for future protocol additions.
The client generates an x402 access token with delegated permissions:
- Order permission: "You can charge my account up to X credits"
- Redeem permission: "You can consume X credits from my balance"
The server verifies the token, executes the AI workload, and settles payment—all in a single request lifecycle.
Real-World Impact
For Agent Builders
You can monetize your AI agent in minutes:
import { paymentMiddleware } from '@nevermined-io/payments/express'
app.use(paymentMiddleware(payments, {
'POST /ask': { planId: PLAN_ID, credits: 1 }
}))
One line of code. Your endpoint is now payment-protected.
For Agent Consumers
Your agents can autonomously pay for services:
const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId)
const response = await fetch('https://api.example.com/ask', {
headers: { 'payment-signature': accessToken }
})
No pre-purchase required. No balance checks. The smart account handles everything.
For Enterprises
- Budget Controls: Set spending limits per agent, per day, per department
- Audit Trails: Every payment is verified and settled on-chain
- Flexible Billing: Credits, subscriptions, usage-based, or outcome-based pricing
The Bigger Picture: Agent-to-Agent Commerce
The x402 protocol enables a new economy where AI agents can:
- Discover services through standard HTTP responses
- Negotiate payments using standardized headers
- Execute transactions without human intervention
- Verify receipts through blockchain settlement
Imagine an AI research assistant that automatically pays for:
- API calls to a specialized medical knowledge base
- Compute time on a GPU inference cluster
- Access to premium data feeds
All happening in milliseconds, with cryptographic verification, and complete audit trails.
Getting Started
Ready to add payments to your AI agent?
- Create a Nevermined account at nevermined.app
- Register your agent and create a payment plan
- Add the Express middleware to your server
- Generate x402 tokens in your client
For step-by-step instructions, check out our 5-minute quickstart.
Beyond HTTP: Multi-Protocol Support
x402 is our foundation for HTTP-based payments, but we've already extended the same payment infrastructure to other AI protocols:
- Google A2A Integration: Nevermined payments work seamlessly with Google's Agent-to-Agent protocol, enabling autonomous agent commerce with standardized discovery and communication
- MCP Tool Payments: Monetize your Model Context Protocol tools—charge per tool invocation with the same credit-based system
Whether your agents communicate via HTTP, A2A, or MCP, Nevermined provides unified payment rails.
The future of AI is autonomous agents transacting with each other at machine speed. We're building the financial infrastructure to make it happen.
Nevermined is building financial infrastructure for AI agents. Learn more at nevermined.ai.
Technical Deep-Dive: The x402 Flow
For those who want to understand the protocol mechanics:
Step 1: Payment Discovery
GET /api/agent/ask HTTP/1.1
Host: api.example.com
HTTP/1.1 402 Payment Required
payment-required: eyJ4NDAyVmVyc2lvbiI6MiwiYWNjZXB0cyI6Wy4uLl19
The payment-required header is a base64-encoded JSON object specifying:
- Accepted payment schemes
- Network (chain) for settlement
- Plan identifier
- Optional agent identifier
Step 2: Token Generation
The client SDK generates an x402 access token containing:
{
"x402Version": 2,
"resource": {
"url": "/api/v1/agents/809184270231.../tasks",
"description": "AI agent task execution",
"mimeType": "application/json"
},
"accepted": {
"scheme": "nvm:erc4337",
"network": "eip155:84532",
"planId": "44742763076047497640080230236781474129970992727896593861997347135613135571071",
"extra": {
"version": "1",
"agentId": "80918427023170428029540261117198154464497879145267720259488529685089104529015"
}
},
"payload": {
"signature": "0x01845ADb2C711129d4f3966735eD98a9F09fC4cE...",
"authorization": {
"from": "0xD4f58B60330bC59cB0A07eE6A1A66ad64244eC8c",
"sessionKeysProvider": "zerodev",
"sessionKeys": [
{ "id": "order", "data": "0x20a13d82dd9ee289..." },
{ "id": "redeem", "data": "0x68e8e34d65914908..." }
]
}
},
"extensions": {}
}
The accepted field echoes the server's payment requirements, confirming which scheme the client chose. The payload contains the cryptographic authorization with session keys that delegate specific permissions to the facilitator.
Step 3: Verification & Settlement
The server sends the token to the Nevermined Facilitator:
- Verify: Check signature, session key validity, and balance
- Execute: Perform the AI workload
- Settle: Burn credits on-chain
Step 4: Receipt
The server returns a settlement receipt in the payment-response header:
{
"success": true,
"creditsRedeemed": 1,
"transactionHash": "0x..."
}
This provides cryptographic proof that payment was processed.
For the complete technical specification, see our x402 Smart Accounts Spec.

See Nevermined
in Action
Real-time payments, flexible pricing, and outcome-based monetization—all in one platform.



