@nevermined-io/openclaw-plugin 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tools.js CHANGED
@@ -1,4 +1,19 @@
1
+ import { getEffectivePlans } from './config.js';
1
2
  const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
3
+ /**
4
+ * Resolve the default planId for the given payment type using the
5
+ * config.plans array (preferred) or legacy planId/fiatPlanId fields.
6
+ */
7
+ function resolveDefaultPlanId(config, paymentType) {
8
+ const plans = getEffectivePlans(config);
9
+ const match = plans.find((p) => p.paymentType === paymentType);
10
+ if (match)
11
+ return match.planId;
12
+ // Fallback: return first plan regardless of type
13
+ if (plans.length > 0)
14
+ return plans[0].planId;
15
+ return undefined;
16
+ }
2
17
  /**
3
18
  * Creates all Nevermined payment tools for the OpenClaw plugin.
4
19
  * Each tool is an object with { name, description, parameters, execute }
@@ -18,7 +33,7 @@ export function createTools(getPayments, config) {
18
33
  },
19
34
  },
20
35
  async execute(_id, params) {
21
- const planId = str(params, 'planId') ?? config.planId;
36
+ const planId = str(params, 'planId') ?? resolveDefaultPlanId(config, 'crypto');
22
37
  if (!planId)
23
38
  throw new Error('planId is required — provide it as a parameter or in the plugin config');
24
39
  const balance = await getPayments().plans.getPlanBalance(planId);
@@ -33,27 +48,33 @@ export function createTools(getPayments, config) {
33
48
  {
34
49
  name: 'nevermined_getAccessToken',
35
50
  label: 'Nevermined Get Access Token',
36
- description: 'Get an x402 access token for authenticating requests to a Nevermined agent',
51
+ description: 'Get an x402 access token for authenticating requests to a Nevermined agent. Supports crypto (default) and fiat (credit card) payment types.',
37
52
  parameters: {
38
53
  type: 'object',
39
54
  properties: {
40
55
  planId: { type: 'string', description: 'The payment plan ID' },
41
56
  agentId: { type: 'string', description: 'The agent ID' },
57
+ paymentType: { type: 'string', description: '"crypto" (default, nvm:erc4337 scheme) or "fiat" (nvm:card-delegation scheme)' },
58
+ paymentMethodId: { type: 'string', description: 'Stripe payment method ID (pm_...). Required for fiat; auto-selects first enrolled card if omitted.' },
59
+ spendingLimitCents: { type: 'number', description: 'Max spend in cents for fiat (default: 1000 = $10)' },
60
+ delegationDurationSecs: { type: 'number', description: 'Delegation duration in seconds for fiat (default: 3600 = 1 hour)' },
42
61
  },
43
62
  },
44
63
  async execute(_id, params) {
45
- const planId = str(params, 'planId') ?? config.planId;
64
+ const paymentType = str(params, 'paymentType') ?? config.paymentType ?? 'crypto';
65
+ const planId = str(params, 'planId') ?? resolveDefaultPlanId(config, paymentType);
46
66
  if (!planId)
47
67
  throw new Error('planId is required — provide it as a parameter or in the plugin config');
48
68
  const agentId = str(params, 'agentId') ?? config.agentId;
49
- const token = await getPayments().x402.getX402AccessToken(planId, agentId);
69
+ const tokenOptions = await buildTokenOptions(getPayments, params, config);
70
+ const token = await getPayments().x402.getX402AccessToken(planId, agentId, undefined, undefined, undefined, tokenOptions);
50
71
  return result({ accessToken: token.accessToken });
51
72
  },
52
73
  },
53
74
  {
54
75
  name: 'nevermined_orderPlan',
55
76
  label: 'Nevermined Order Plan',
56
- description: 'Order (purchase) a Nevermined payment plan',
77
+ description: 'Order (purchase) a Nevermined crypto payment plan',
57
78
  parameters: {
58
79
  type: 'object',
59
80
  properties: {
@@ -61,17 +82,48 @@ export function createTools(getPayments, config) {
61
82
  },
62
83
  },
63
84
  async execute(_id, params) {
64
- const planId = str(params, 'planId') ?? config.planId;
85
+ const planId = str(params, 'planId') ?? resolveDefaultPlanId(config, 'crypto');
65
86
  if (!planId)
66
87
  throw new Error('planId is required — provide it as a parameter or in the plugin config');
67
88
  const res = await getPayments().plans.orderPlan(planId);
68
89
  return result(res);
69
90
  },
70
91
  },
92
+ {
93
+ name: 'nevermined_orderFiatPlan',
94
+ label: 'Nevermined Order Fiat Plan',
95
+ description: 'Order a fiat payment plan — returns a Stripe checkout URL for completing the purchase',
96
+ parameters: {
97
+ type: 'object',
98
+ properties: {
99
+ planId: { type: 'string', description: 'The payment plan ID to order' },
100
+ },
101
+ },
102
+ async execute(_id, params) {
103
+ const planId = str(params, 'planId') ?? resolveDefaultPlanId(config, 'fiat');
104
+ if (!planId)
105
+ throw new Error('planId is required — provide it as a parameter or in the plugin config');
106
+ const res = await getPayments().plans.orderFiatPlan(planId);
107
+ return result(res);
108
+ },
109
+ },
110
+ {
111
+ name: 'nevermined_listPaymentMethods',
112
+ label: 'Nevermined List Payment Methods',
113
+ description: 'List enrolled credit cards available for fiat payments',
114
+ parameters: {
115
+ type: 'object',
116
+ properties: {},
117
+ },
118
+ async execute() {
119
+ const methods = await getPayments().delegation.listPaymentMethods();
120
+ return result(methods);
121
+ },
122
+ },
71
123
  {
72
124
  name: 'nevermined_queryAgent',
73
125
  label: 'Nevermined Query Agent',
74
- description: 'Query a Nevermined AI agent end-to-end: acquires an x402 access token, sends the prompt to the agent, and returns the response',
126
+ description: 'Query a Nevermined AI agent end-to-end: acquires an x402 access token, sends the prompt to the agent, and returns the response. Supports crypto (default) and fiat (credit card) payment types.',
75
127
  parameters: {
76
128
  type: 'object',
77
129
  properties: {
@@ -80,18 +132,24 @@ export function createTools(getPayments, config) {
80
132
  planId: { type: 'string', description: 'The payment plan ID' },
81
133
  agentId: { type: 'string', description: 'The agent ID' },
82
134
  method: { type: 'string', description: 'HTTP method (default: POST)' },
135
+ paymentType: { type: 'string', description: '"crypto" (default, nvm:erc4337 scheme) or "fiat" (nvm:card-delegation scheme)' },
136
+ paymentMethodId: { type: 'string', description: 'Stripe payment method ID (pm_...). Required for fiat; auto-selects first enrolled card if omitted.' },
137
+ spendingLimitCents: { type: 'number', description: 'Max spend in cents for fiat (default: 1000 = $10)' },
138
+ delegationDurationSecs: { type: 'number', description: 'Delegation duration in seconds for fiat (default: 3600 = 1 hour)' },
83
139
  },
84
140
  required: ['agentUrl', 'prompt'],
85
141
  },
86
142
  async execute(_id, params) {
87
143
  const agentUrl = requireStr(params, 'agentUrl');
88
144
  const prompt = requireStr(params, 'prompt');
89
- const planId = str(params, 'planId') ?? config.planId;
145
+ const paymentType = str(params, 'paymentType') ?? config.paymentType ?? 'crypto';
146
+ const planId = str(params, 'planId') ?? resolveDefaultPlanId(config, paymentType);
90
147
  if (!planId)
91
148
  throw new Error('planId is required — provide it as a parameter or in the plugin config');
92
149
  const agentId = str(params, 'agentId') ?? config.agentId;
93
150
  const method = str(params, 'method') ?? 'POST';
94
- const { accessToken } = await getPayments().x402.getX402AccessToken(planId, agentId);
151
+ const tokenOptions = await buildTokenOptions(getPayments, params, config);
152
+ const { accessToken } = await getPayments().x402.getX402AccessToken(planId, agentId, undefined, undefined, undefined, tokenOptions);
95
153
  const response = await fetch(agentUrl, {
96
154
  method,
97
155
  headers: {
@@ -101,8 +159,11 @@ export function createTools(getPayments, config) {
101
159
  body: method !== 'GET' ? JSON.stringify({ prompt }) : undefined,
102
160
  });
103
161
  if (response.status === 402) {
162
+ const guidance = paymentType === 'fiat'
163
+ ? 'Order a fiat plan using nevermined_orderFiatPlan, or enroll a card at nevermined.app.'
164
+ : 'Order the plan first using nevermined_orderPlan, or try paymentType "fiat" if the plan supports card payments.';
104
165
  return result({
105
- error: 'Payment required — insufficient credits. Order the plan first using nevermined_orderPlan.',
166
+ error: `Payment required — insufficient credits. ${guidance}`,
106
167
  status: 402,
107
168
  });
108
169
  }
@@ -128,10 +189,11 @@ export function createTools(getPayments, config) {
128
189
  description: { type: 'string', description: 'Agent description' },
129
190
  agentUrl: { type: 'string', description: 'The endpoint URL for the agent' },
130
191
  planName: { type: 'string', description: 'Name for the payment plan' },
131
- priceAmounts: { type: 'string', description: 'Comma-separated price amounts in wei' },
192
+ priceAmounts: { type: 'string', description: 'Comma-separated price amounts in wei (crypto) or cents (fiat)' },
132
193
  priceReceivers: { type: 'string', description: 'Comma-separated receiver addresses' },
133
194
  creditsAmount: { type: 'number', description: 'Number of credits in the plan' },
134
195
  tokenAddress: { type: 'string', description: 'ERC20 token address (e.g. USDC). Omit for native token.' },
196
+ pricingType: { type: 'string', description: '"crypto" (default), "erc20", or "fiat"' },
135
197
  },
136
198
  required: ['name', 'agentUrl', 'planName', 'priceAmounts', 'priceReceivers', 'creditsAmount'],
137
199
  },
@@ -148,10 +210,12 @@ export function createTools(getPayments, config) {
148
210
  .map((s) => s.trim());
149
211
  const creditsAmount = Number(requireStr(params, 'creditsAmount'));
150
212
  const tokenAddress = str(params, 'tokenAddress');
213
+ const pricingType = (str(params, 'pricingType') ?? 'crypto');
214
+ const isCrypto = pricingType !== 'fiat';
151
215
  const priceConfig = {
152
216
  amounts: priceAmounts,
153
217
  receivers: priceReceivers,
154
- isCrypto: true,
218
+ isCrypto,
155
219
  tokenAddress: tokenAddress ?? ZERO_ADDRESS,
156
220
  contractAddress: ZERO_ADDRESS,
157
221
  feeController: ZERO_ADDRESS,
@@ -264,6 +328,27 @@ export function createTools(getPayments, config) {
264
328
  },
265
329
  ];
266
330
  }
331
+ // --- Helpers ---
332
+ async function buildTokenOptions(getPayments, params, config) {
333
+ const paymentType = str(params, 'paymentType') ?? config.paymentType ?? 'crypto';
334
+ if (paymentType !== 'fiat')
335
+ return undefined;
336
+ let paymentMethodId = str(params, 'paymentMethodId');
337
+ if (!paymentMethodId) {
338
+ const methods = await getPayments().delegation.listPaymentMethods();
339
+ if (methods.length === 0)
340
+ throw new Error('No enrolled payment methods found. Enroll a card at https://nevermined.app');
341
+ paymentMethodId = methods[0].id;
342
+ }
343
+ return {
344
+ scheme: 'nvm:card-delegation',
345
+ delegationConfig: {
346
+ providerPaymentMethodId: paymentMethodId,
347
+ spendingLimitCents: Number(str(params, 'spendingLimitCents') ?? config.defaultSpendingLimitCents ?? 1000),
348
+ durationSecs: Number(str(params, 'delegationDurationSecs') ?? config.defaultDelegationDurationSecs ?? 3600),
349
+ },
350
+ };
351
+ }
267
352
  function result(payload) {
268
353
  return {
269
354
  content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
package/dist/tools.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","s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AM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;IACrB,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,SAAS,CAAA;IAC/D,OAAO,MAAM,CAAC,CAAC,CAAC,CAAA;AAClB,CAAC;AAED,SAAS,UAAU,CAAC,MAA+B,EAAE,GAAW;IAC9D,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAA;IAC7D,OAAO,CAAC,CAAA;AACV,CAAC"}
package/docs/commands.md CHANGED
@@ -1,24 +1,27 @@
1
1
  ---
2
- title: "Commands"
2
+ title: "API Reference"
3
3
  description: "All available tools and slash commands in the Nevermined OpenClaw plugin"
4
4
  icon: "terminal"
5
5
  ---
6
6
 
7
- # Commands
7
+ # API Reference
8
8
 
9
- The plugin provides slash commands for chat channels and gateway methods for programmatic access. Each command is available in both forms.
9
+ The plugin provides slash commands for chat channels and tools that agents can invoke on behalf of users. Slash commands are triggered directly by users with the `/` prefix, while tools are called by the AI agent in response to natural language requests.
10
10
 
11
- ## Authentication
11
+ ## Authentication Commands
12
12
 
13
- ### `/nvm_login [environment]`
13
+ ### Log In — `/nvm_login`
14
14
 
15
- Authenticate with Nevermined via browser login.
15
+ Authenticate with the Nevermined platform to enable all payment tools. The plugin supports three authentication flows: automatic browser login, environment selection, and direct API key input.
16
+
17
+ When using browser login, the plugin starts a temporary local server, opens your default browser to the Nevermined login page, and captures the API key automatically after you sign in. On headless servers where no browser is available, paste your API key directly.
16
18
 
17
19
  | Parameter | Type | Required | Default | Description |
18
20
  |-----------|------|----------|---------|-------------|
19
21
  | `environment` | string | No | `sandbox` | `sandbox` or `live` |
20
22
 
21
- **Example:**
23
+ > **Example prompt:** "Log me in to Nevermined"
24
+
22
25
  ```
23
26
  /nvm_login
24
27
  /nvm_login live
@@ -27,24 +30,29 @@ Authenticate with Nevermined via browser login.
27
30
 
28
31
  ---
29
32
 
30
- ### `/nvm_logout`
33
+ ### Log Out — `/nvm_logout`
31
34
 
32
- Log out from Nevermined and remove the stored API key.
35
+ End your Nevermined session and remove the stored API key from memory. After logging out, all payment tools will be unavailable until you authenticate again. Use this when switching accounts or when you want to revoke the current session for security.
33
36
 
34
37
  ---
35
38
 
36
39
  ## Subscriber Tools
37
40
 
38
- These tools are for users who want to subscribe to plans, check balances, and query agents.
41
+ These tools are designed for users who consume paid AI agent services. They handle the full lifecycle of subscribing to a plan, paying for access, and querying agents.
39
42
 
40
- ### `nevermined_checkBalance`
43
+ ### Check Credit Balance — `nevermined_checkBalance`
41
44
 
42
- Check the credit balance for a payment plan.
45
+ Retrieve the current credit balance for a payment plan. This is useful to verify how many credits remain before making requests, or to confirm that a recent purchase was credited to your account. The response includes the plan name, remaining balance, and whether you are an active subscriber.
46
+
47
+ If a `planId` is configured in the plugin settings, it is used by default. You can override it per call.
43
48
 
44
49
  | Parameter | Type | Required | Default | Description |
45
50
  |-----------|------|----------|---------|-------------|
46
51
  | `planId` | string | No | Config `planId` | The payment plan ID to check |
47
52
 
53
+ **Example prompt:**
54
+ > How many credits do I have left on my Weather Forecast plan?
55
+
48
56
  **Returns:**
49
57
  ```json
50
58
  {
@@ -57,14 +65,27 @@ Check the credit balance for a payment plan.
57
65
 
58
66
  ---
59
67
 
60
- ### `nevermined_getAccessToken`
68
+ ### Get Access Token — `nevermined_getAccessToken`
61
69
 
62
- Get an x402 access token for authenticating requests to a Nevermined agent.
70
+ Generate an x402 access token that authorizes requests to a paid Nevermined agent. The token is cryptographically signed and contains delegated permissions (order, burn) that allow the agent to verify and settle payments on your behalf.
71
+
72
+ This tool supports two payment schemes. **Crypto** (the default) uses the `nvm:erc4337` on-chain scheme with session keys and smart accounts. **Fiat** uses the `nvm:card-delegation` scheme, which charges a previously enrolled credit card via Stripe delegation. When using fiat, the plugin automatically looks up your enrolled payment methods and selects the first one unless you specify a `paymentMethodId`.
73
+
74
+ Most users will not need to call this tool directly — `nevermined_queryAgent` handles token acquisition automatically. Use this tool when you need the raw token for custom integrations or debugging.
63
75
 
64
76
  | Parameter | Type | Required | Default | Description |
65
77
  |-----------|------|----------|---------|-------------|
66
78
  | `planId` | string | No | Config `planId` | The payment plan ID |
67
79
  | `agentId` | string | No | Config `agentId` | The agent ID |
80
+ | `paymentType` | string | No | Config `paymentType` or `"crypto"` | `"crypto"` (nvm:erc4337 scheme) or `"fiat"` (nvm:card-delegation scheme) |
81
+ | `paymentMethodId` | string | No | Auto-selects first enrolled card | Stripe payment method ID (`pm_...`). Only used for fiat. |
82
+ | `spendingLimitCents` | number | No | Config `defaultSpendingLimitCents` or `1000` | Max spend in cents. Only used for fiat. |
83
+ | `delegationDurationSecs` | number | No | Config `defaultDelegationDurationSecs` or `3600` | Delegation duration in seconds. Only used for fiat. |
84
+
85
+ **Example prompt:**
86
+ > Get me an access token for the Weather Oracle agent so I can call it from my script.
87
+
88
+ > **Example prompt:** "Get me an access token for the translation agent"
68
89
 
69
90
  **Returns:**
70
91
  ```json
@@ -75,21 +96,84 @@ Get an x402 access token for authenticating requests to a Nevermined agent.
75
96
 
76
97
  ---
77
98
 
78
- ### `nevermined_orderPlan`
99
+ ### Purchase a Crypto Plan — `nevermined_orderPlan`
100
+
101
+ Purchase a payment plan using cryptocurrency. This initiates an on-chain transaction that transfers the plan's price to the builder's wallet and credits your account with the plan's allotted credits. The transaction is processed through the Nevermined Protocol smart contracts.
79
102
 
80
- Purchase (order) a Nevermined payment plan.
103
+ Use this for plans priced in native tokens (ETH, MATIC) or ERC-20 tokens (USDC). For plans priced in fiat currency, use `nevermined_orderFiatPlan` instead.
81
104
 
82
105
  | Parameter | Type | Required | Default | Description |
83
106
  |-----------|------|----------|---------|-------------|
84
107
  | `planId` | string | No | Config `planId` | The plan ID to purchase |
85
108
 
109
+ **Example prompt:**
110
+ > Buy the Weather Forecast plan so I can start querying the agent.
111
+
86
112
  **Returns:** Order confirmation with transaction hash.
87
113
 
88
114
  ---
89
115
 
90
- ### `nevermined_queryAgent`
116
+ ### Purchase a Fiat Plan — `nevermined_orderFiatPlan`
91
117
 
92
- End-to-end agent query: acquires an x402 access token, sends the prompt to the agent URL with the `PAYMENT-SIGNATURE` header, and returns the response.
118
+ Purchase a payment plan using fiat currency (USD). Instead of executing an on-chain transaction, this tool returns a Stripe checkout URL where you complete the payment in a browser. Once the payment is confirmed, credits are added to your account.
119
+
120
+ Use this for plans that have been created with `pricingType: fiat`. For crypto-priced plans, use `nevermined_orderPlan` instead.
121
+
122
+ | Parameter | Type | Required | Default | Description |
123
+ |-----------|------|----------|---------|-------------|
124
+ | `planId` | string | No | Config `planId` | The plan ID to purchase |
125
+
126
+ **Example prompt:**
127
+ > I want to subscribe to the Premium Agent plan using my credit card.
128
+
129
+ **Returns:**
130
+ ```json
131
+ {
132
+ "result": {
133
+ "checkoutUrl": "https://checkout.stripe.com/..."
134
+ }
135
+ }
136
+ ```
137
+
138
+ ---
139
+
140
+ ### List Payment Methods — `nevermined_listPaymentMethods`
141
+
142
+ Retrieve the list of credit cards you have enrolled for fiat payments. Cards are enrolled through the [Nevermined App](https://nevermined.app) under Settings > Payment Methods. Each entry includes the card brand, last four digits, and expiration date.
143
+
144
+ This is useful to verify which cards are available before making a fiat payment, or to find the `paymentMethodId` for a specific card when you have multiple cards enrolled.
145
+
146
+ No parameters required.
147
+
148
+ **Example prompt:**
149
+ > Which credit cards do I have on file for Nevermined payments?
150
+
151
+ **Returns:**
152
+ ```json
153
+ [
154
+ {
155
+ "id": "pm_...",
156
+ "brand": "visa",
157
+ "last4": "4242",
158
+ "expMonth": 12,
159
+ "expYear": 2027
160
+ }
161
+ ]
162
+ ```
163
+
164
+ ---
165
+
166
+ ### Query a Paid Agent — `nevermined_queryAgent`
167
+
168
+ Send a prompt to a paid Nevermined AI agent and get the response. This is the main tool for interacting with agents — it handles the full payment lifecycle in a single call:
169
+
170
+ 1. Acquires an x402 access token (crypto or fiat, depending on `paymentType`)
171
+ 2. Sends the prompt to the agent's URL with the `PAYMENT-SIGNATURE` header
172
+ 3. Returns the agent's response
173
+
174
+ If the agent returns a 402 (Payment Required) response, the tool returns an error suggesting you purchase credits first. This typically means your plan has run out of credits or you haven't subscribed yet.
175
+
176
+ Like `nevermined_getAccessToken`, this tool supports both crypto and fiat payment types. When using fiat, it automatically resolves your enrolled card and builds the delegation config.
93
177
 
94
178
  | Parameter | Type | Required | Default | Description |
95
179
  |-----------|------|----------|---------|-------------|
@@ -98,18 +182,29 @@ End-to-end agent query: acquires an x402 access token, sends the prompt to the a
98
182
  | `planId` | string | No | Config `planId` | The payment plan ID |
99
183
  | `agentId` | string | No | Config `agentId` | The agent ID |
100
184
  | `method` | string | No | `POST` | HTTP method |
185
+ | `paymentType` | string | No | Config `paymentType` or `"crypto"` | `"crypto"` (nvm:erc4337 scheme) or `"fiat"` (nvm:card-delegation scheme) |
186
+ | `paymentMethodId` | string | No | Auto-selects first enrolled card | Stripe payment method ID (`pm_...`). Only used for fiat. |
187
+ | `spendingLimitCents` | number | No | Config `defaultSpendingLimitCents` or `1000` | Max spend in cents. Only used for fiat. |
188
+ | `delegationDurationSecs` | number | No | Config `defaultDelegationDurationSecs` or `3600` | Delegation duration in seconds. Only used for fiat. |
189
+
190
+ **Example prompts:**
191
+ > Ask the Weather Oracle at https://weather.example.com/agent what the forecast is for Barcelona.
101
192
 
102
- If the agent returns a 402 (Payment Required) response, the tool returns an error indicating insufficient credits.
193
+ > Query the translation agent at https://translate.example.com/tasks to translate "hello world" into French, and pay with my credit card.
103
194
 
104
195
  ---
105
196
 
106
197
  ## Builder Tools
107
198
 
108
- These tools are for agent builders who want to register agents and create payment plans.
199
+ These tools are designed for agent builders who want to register their AI agents on the Nevermined marketplace and create payment plans that subscribers can purchase.
200
+
201
+ ### Register an Agent — `nevermined_registerAgent`
109
202
 
110
- ### `nevermined_registerAgent`
203
+ Register a new AI agent on Nevermined and create an associated payment plan in a single operation. This publishes your agent to the Nevermined marketplace, making it discoverable and purchasable by subscribers.
111
204
 
112
- Register a new AI agent with an associated payment plan.
205
+ The tool creates both the agent record (with its endpoint URL) and a payment plan (with pricing and credit allocation). The `pricingType` parameter controls how the plan is priced: `"crypto"` for native blockchain tokens, `"erc20"` for stablecoins like USDC, or `"fiat"` for USD pricing via Stripe.
206
+
207
+ After registration, the returned `agentId` and `planId` should be saved in your plugin config for the paid endpoint to work.
113
208
 
114
209
  | Parameter | Type | Required | Description |
115
210
  |-----------|------|----------|-------------|
@@ -117,10 +212,16 @@ Register a new AI agent with an associated payment plan.
117
212
  | `description` | string | No | Agent description |
118
213
  | `agentUrl` | string | **Yes** | The endpoint URL for the agent |
119
214
  | `planName` | string | **Yes** | Name for the payment plan |
120
- | `priceAmounts` | string | **Yes** | Comma-separated price amounts in wei |
215
+ | `priceAmounts` | string | **Yes** | Comma-separated price amounts in wei (crypto) or cents (fiat) |
121
216
  | `priceReceivers` | string | **Yes** | Comma-separated receiver addresses |
122
217
  | `creditsAmount` | number | **Yes** | Number of credits in the plan |
123
218
  | `tokenAddress` | string | No | ERC20 token address (e.g. USDC). Omit for native token. |
219
+ | `pricingType` | string | No | `"crypto"` (default), `"erc20"`, or `"fiat"` |
220
+
221
+ **Example prompt:**
222
+ > Register a new agent called "Code Review Bot" at https://my-server.com/nevermined/agent with a plan named "Code Review" priced at 1000000 (1 USDC) to address 0xABC... with token 0x036CbD... granting 10 credits.
223
+
224
+ > **Example prompt:** "Register my translation agent hosted at https://agent.example.com with a plan named 'Translation Plan' that costs 1000000 wei (1 USDC) sent to address 0x123... for 100 credits"
124
225
 
125
226
  **Returns:**
126
227
  ```json
@@ -133,19 +234,25 @@ Register a new AI agent with an associated payment plan.
133
234
 
134
235
  ---
135
236
 
136
- ### `nevermined_createPlan`
237
+ ### Create a Payment Plan — `nevermined_createPlan`
137
238
 
138
- Create a standalone payment plan (without an agent).
239
+ Create a standalone payment plan without associating it with an agent. This is useful when you want to manage plans separately from agents, or when a single plan should grant access to multiple agents.
240
+
241
+ The plan can be priced in three ways: `"fiat"` sets the price in USD cents (e.g. `"100"` = $1.00) and subscribers pay via Stripe, `"erc20"` sets the price in an ERC-20 token's smallest unit (e.g. `"1000000"` = 1 USDC) and requires a `tokenAddress`, and `"crypto"` (the default) sets the price in the blockchain's native token.
139
242
 
140
243
  | Parameter | Type | Required | Description |
141
244
  |-----------|------|----------|-------------|
142
245
  | `name` | string | **Yes** | Plan name |
143
246
  | `description` | string | No | Plan description |
144
- | `priceAmounts` | string | **Yes** | Comma-separated price amounts in wei |
145
- | `priceReceivers` | string | **Yes** | Comma-separated receiver addresses |
247
+ | `priceAmount` | string | **Yes** | Price in cents for fiat (e.g. "100" = $1.00), in token smallest unit for crypto |
248
+ | `receiver` | string | **Yes** | Receiver wallet address (0x...) |
146
249
  | `creditsAmount` | number | **Yes** | Number of credits in the plan |
250
+ | `pricingType` | string | No | `"fiat"` for Stripe/USD, `"erc20"` for ERC20 tokens, `"crypto"` for native token (default) |
147
251
  | `accessLimit` | string | No | `"credits"` (default) or `"time"` |
148
- | `tokenAddress` | string | No | ERC20 token address (e.g. USDC). Omit for native token. |
252
+ | `tokenAddress` | string | No | ERC20 token contract address. Required when pricingType is "erc20". |
253
+
254
+ **Example prompt:**
255
+ > Create a fiat payment plan called "Pro Tier" at $5.00 (500 cents) to wallet 0xABC... with 50 credits.
149
256
 
150
257
  **Returns:**
151
258
  ```json
@@ -156,8 +263,13 @@ Create a standalone payment plan (without an agent).
156
263
 
157
264
  ---
158
265
 
159
- ### `nevermined_listPlans`
266
+ ### List My Plans — `nevermined_listPlans`
267
+
268
+ Retrieve all payment plans owned by the authenticated builder. This returns the full list of plans you have created, including their IDs, names, and configuration. Useful for finding a `planId` to use with other tools or to review your current offerings.
269
+
270
+ No parameters required.
160
271
 
161
- List the builder's payment plans. No parameters required.
272
+ **Example prompt:**
273
+ > Show me all the payment plans I've created on Nevermined.
162
274
 
163
275
  **Returns:** Array of plan objects.
@@ -24,6 +24,10 @@ openclaw plugin install @nevermined-io/openclaw-plugin
24
24
 
25
25
  ## Authentication
26
26
 
27
+ <Note>
28
+ To interact with the Nevermined API, you need an API key. Follow the [Get Your API Key](/docs/getting-started/get-your-api-key) guide to create one.
29
+ </Note>
30
+
27
31
  ### Option A: Browser login (recommended)
28
32
 
29
33
  Use the `/nvm_login` command from any connected chat channel:
@@ -40,6 +44,12 @@ To target the live environment:
40
44
  /nvm_login live
41
45
  ```
42
46
 
47
+ To use a specific API key:
48
+
49
+ ```
50
+ /nvm_login sandbox:eyJhbG...
51
+ ```
52
+
43
53
  ### Option B: Manual configuration
44
54
 
45
55
  Add your API key directly to `openclaw.json`:
@@ -48,7 +58,7 @@ Add your API key directly to `openclaw.json`:
48
58
  {
49
59
  "plugins": {
50
60
  "entries": {
51
- "nevermined": {
61
+ "openclaw-plugin": {
52
62
  "enabled": true,
53
63
  "config": {
54
64
  "nvmApiKey": "sandbox:eyJhbG...",
@@ -60,15 +70,17 @@ Add your API key directly to `openclaw.json`:
60
70
  }
61
71
  ```
62
72
 
63
- You can obtain an API key from the [Nevermined App](https://nevermined.app) under Settings > API Keys. See the [Get Your API Key](/docs/getting-started/get-your-api-key) guide for details.
64
-
65
73
  ## Quick Test
66
74
 
67
75
  After authenticating, verify the plugin is working:
68
76
 
69
- 1. **Check your balance** — from any chat channel, the agent can call `nevermined_checkBalance` to verify connectivity.
77
+ 1. **Check your balance** — from any chat channel, the agent can ask `Example prompt: “How many credits do I have left on my plan?”` to verify connectivity.
78
+
79
+ 2. **List plans** — you can ask `Example prompt: Show me all my payment plans”` to see available payment plans.
80
+
81
+ ## Fiat Payments
70
82
 
71
- 2. **List plans** call `nevermined_listPlans` to see available payment plans.
83
+ The plugin also supports fiat payments via credit card delegation. Enroll a card at [nevermined.app](https://nevermined.app), then use `paymentType: fiat` with any token or query tool. See the [guide](./guide.md#fiat-payments-credit-card) for details.
72
84
 
73
85
  ## Next Steps
74
86