Building a Paid AI Agent with OpenClaw and Nevermined
The Nevermined OpenClaw plugin lets you monetize AI agents directly from chat channels. Subscribers pay per-request using the x402 payment protocol, and builders collect revenue automatically through on-chain payment plans. This guide walks through building a Weather Oracle — a paid agent that serves weather forecasts and charges 1 credit per request.What You Get
The plugin adds 7 payment tools and 2 slash commands to your OpenClaw gateway: Subscriber tools — for users who consume paid services:| Tool | Purpose |
|---|---|
nevermined_checkBalance | Check remaining credits on a plan |
nevermined_getAccessToken | Get an x402 token for authenticating requests |
nevermined_orderPlan | Purchase a payment plan |
nevermined_queryAgent | Send a paid query to an agent (end-to-end) |
| Tool | Purpose |
|---|---|
nevermined_registerAgent | Register an agent with a payment plan |
nevermined_createPlan | Create a standalone payment plan |
nevermined_listPlans | List your payment plans |
/nvm_login and /nvm_logout for authentication.
Paid HTTP endpoint: An x402-compatible endpoint on the gateway that handles payment verification, request processing, and credit settlement automatically.
Prerequisites
- An OpenClaw gateway instance (v2026.2+)
- Node.js >= 18
- A Nevermined account with an API key
Step 1: Install the Plugin
From your OpenClaw gateway server:~/.openclaw/extensions/nevermined/.
After installation, restart the gateway:
Step 2: Authenticate
Send/nvm_login from any connected chat channel (Telegram, Discord, etc.). The plugin supports two flows:
Browser login (if your server has a display):
sandbox for testing, live for production.
Step 3: Register Your Agent and Payment Plan
Ask your Claw to register an agent. In any chat channel, send a message like:Register a Nevermined agent called “Weather Oracle” at URLThe agent will callhttps://my-gateway.example.com/nevermined/agentwith a plan named “Weather Forecast” priced at 1000000 (1 USDC) to address0xYourWalletAddresswith token0x036CbD53842c5426634e7929541eC2318f3dCF7egranting 5 credits.
nevermined_registerAgent with these parameters:
| Parameter | Value | Description |
|---|---|---|
name | Weather Oracle | Display name on Nevermined |
agentUrl | https://my-gateway.example.com/nevermined/agent | Public URL of your paid endpoint |
planName | Weather Forecast | Name for the payment plan |
priceAmounts | 1000000 | Price in token units (1 USDC = 1,000,000 wei) |
priceReceivers | 0xYourWalletAddress | Your wallet that receives payments |
creditsAmount | 5 | Credits granted per purchase |
tokenAddress | 0x036CbD53842c5426634e7929541eC2318f3dCF7e | USDC on Base Sepolia. Omit for native token. |
agentId and planId — save these for the next step.
Step 4: Enable the Paid Endpoint
Add the returned IDs and enable the paid endpoint in your gateway config (~/.openclaw/openclaw.json):
- Extracts the
payment-signatureheader from incoming requests - Calls
verifyPermissionsto check the subscriber has credits - Processes the request (runs your agent handler)
- Calls
settlePermissionsto burn credits - Returns the response with a
payment-responseheader
Configuration Reference
| Field | Required | Default | Description |
|---|---|---|---|
nvmApiKey | No | — | API key (set via /nvm_login or config) |
environment | No | sandbox | sandbox for testing, live for production |
planId | No | — | Default plan ID for tools and the paid endpoint |
agentId | No | — | Default agent ID |
creditsPerRequest | No | 1 | Credits burned per request |
enablePaidEndpoint | No | false | Enable the x402 paid HTTP endpoint |
agentEndpointPath | No | /nevermined/agent | Path for the paid endpoint |
Step 5: Test as a Subscriber
From the same gateway (or a different one with a subscriber API key), test the full flow:Order the plan
Order the Weather Oracle plan <plan-id>
The Claw calls nevermined_orderPlan. You receive 5 credits.
Check your balance
Check my Nevermined balance for plan <plan-id>
Should show 5 credits.
Query the agent
Ask the Weather Oracle at http://localhost:18789/nevermined/agent about the weather in Barcelona
The Claw calls nevermined_queryAgent, which:
- Acquires an x402 access token
- Sends the prompt with a
PAYMENT-SIGNATUREheader - The paid endpoint verifies, processes, and settles
- Returns the weather forecast
Verify credit burn
Check my balance againShould show 4 credits — one was consumed.
Custom Agent Handlers
The plugin includes a mock weather handler for demonstration. To use your own logic, pass a customagentHandler when registering the plugin:
{ prompt: string } and returns any JSON-serializable object.
Credit Balance Awareness
When the plugin is authenticated and aplanId is configured, it automatically injects the current credit balance into the agent’s context before each prompt. This means your Claw can proactively warn users when credits are running low:
“You have 2 credits remaining on the Weather Forecast plan. Consider ordering more credits.”The balance is cached for 60 seconds to avoid excessive API calls.
How It Works
The plugin implements the x402 payment protocol for agent-to-agent payments:verifyPermissions step checks the subscriber’s balance without burning credits, and settlePermissions burns them only after successful processing.
Next Steps
- Commands Reference — full parameter documentation for all tools
- Setup Reference — detailed configuration options
- Nevermined Docs — platform documentation
- x402 Protocol — payment protocol specification
- OpenClaw Plugin Development — building OpenClaw plugins