Integration
L402
OpenClaw plugin: models paid per bundle in sats over Lightning (L402), from any Nostr Wallet Connect wallet, within your limits.
Install
openclaw plugins install git:github.com/lamporun/openclaw-l402@v0.1.1
README
# openclaw-l402
An OpenClaw plugin that lets your agent pay for its own model calls in sats. It runs [l402-bridge](https://github.com/lamporun/l402-bridge) inside the Gateway and adds the seller's models as the `l402` provider. When the seller answers 402 Payment Required with a Lightning invoice ([L402](https://github.com/lightninglabs/L402)), the bridge pays it from your wallet over Nostr Wallet Connect, within your limits, and later requests reuse the paid bundle until it runs out. No account, card or API key at the seller.
The plugin is a thin wrapper: every payment rule (limits, never paying twice, receipt checks) lives in l402-bridge, which also runs on its own for other tools.
## Install
```sh
openclaw plugins install git:github.com/lamporun/openclaw-l402@v0.1.1 --accept-capabilities
```
OpenClaw warns that the source is outside ClawHub review: read the code first, it is short (`index.js` and `src/`). The one capability it declares is text inference, for the `l402` provider. Until the plugin is on ClawHub, the Gateway log also says it can't verify where the plugin came from; that is expected for a git install, and the plugin still loads. Requires OpenClaw 2026.11.10 or later and Node 24.
## Set up
1. Create a wallet connection with the `pay_invoice` permission and a small budget, in a wallet that supports Nostr Wallet Connect (Alby Hub, Minibits, Primal, Coinos, Zeus...).
2. Keep the connection string out of `openclaw.json`. Put it in OpenClaw's secret store and point the plugin at it:
```sh
openclaw secrets store set NWC_URL --kind secret --value-file - # paste the string, then Ctrl-D
openclaw config set plugins.entries.l402.config.nwcUrl --ref-source store --ref-provider default --ref-id NWC_URL
```
An environment variable works too (`--ref-source env --ref-id NWC_URL`, with `NWC_URL` set for the Gateway), as do a file or a 1Password or Vault provider: `nwcUrl` takes any [SecretRef](https://docs.openclaw.ai/gateway/secrets). Settings shows it redacted. If `nwcUrl` is unset, the plugin reads `NWC_URL` from the Gateway's environment, like the bridge command.
3. Start or restart the Gateway, give it a few seconds to read the seller's model list, and pick a model:
```sh
openclaw models list --provider l402
openclaw config set agents.defaults.model.primary l402/deepseek-ai/DeepSeek-V4-Flash-0731
```
The bridge starts with the Gateway on `127.0.0.1:8402` and restarts by itself when you change the plugin's settings.
## Settings
All under `plugins.entries.l402.config`:
| Setting | Default | What it does |
|---|---|---|
| `nwcUrl` | `NWC_URL` env | Your wallet connection, as a SecretRef |
| `seller` | `https://lampo.run/v1` | The L402 seller's OpenAI base URL |
| `maxSatsPerPayment` | 1000 | Refuse any single payment above this |
| `maxSatsPerDay` | 10000 | Refuse payments once this much was spent today |
| `port` | 8402 | Loopback port of the bridge |
| `dataDir` | OpenClaw state dir, `plugins/l402` | Paid tokens and the payment log |
| `receipts` | true | Check the seller's signed usage receipt for every answer |
The model list comes from the seller's public rate file (`<seller>/pi402.json`), with names, context windows and prices in USD per million tokens, so OpenClaw's usage view shows what a turn costs. Listing models never pays anything.
## When something is wrong
The chat says why nothing was paid, in the bridge's words, for example:
```
LLM request rejected: l402-bridge: this bundle costs 3,000 sats, above the limit of 1,000 sats per payment. To allow it, set plugins.entries.l402.config.maxSatsPerPayment to 3000 or more, or pick a cheaper model.
```
The same goes for a missing or unresolvable wallet secret, the daily limit, and a wallet that finds no Lightning route to the seller (some small custodial wallets can't reach every seller yet). The Gateway log has the details, and `http://127.0.0.1:8402/l402/status` shows the limits, the bundles left and recent payments, without secrets.
## Security
- The bridge listens on loopback only and refuses browser origins, so a web page can't spend your sats.
- The wallet string reaches the plugin only as the value OpenClaw resolves from your SecretRef; the plugin never writes it anywhere.
- If your agent has shell access on the same machine, assume it can reach the wallet string too. The real ceiling is the budget you set on the wallet connection itself; the plugin's limits guard against loops and bugs, not against an agent that goes looking.
- Prompts are never logged.
## What it costs
An OpenClaw turn sends the agent's whole context, about 20,000 tokens for a fresh session. On lampo.run a DeepSeek V4 Flash bundle is 1,000 sats for about 2.5 million tokens, so roughly a hundred turns; Kimi K3 bundles cost 3,000 sats, above the default per-payment limit. Prices follow the seller's rate file.
## Tested
On 2026-11-27, with OpenClaw 2026.11.10 on Linux and Minibits as the wallet:
| Step | Result |
|---|---|
| `openclaw plugins install git:github.com/lamporun/openclaw-l402` on a fresh install, wallet in OpenClaw's secret store | installed in 12 s, bridge ready inside the Gateway, wallet named in the log |
| `openclaw models list --provider l402` | lampo.run's 8 models, free |
| Agent turn on DeepSeek V4 Flash | answered from an existing bundle in 2 s, receipt verified |
| GLM 5.3 Flash and Kimi K3 with a 1-sat limit | refused, nothing paid, reason shown in the chat |
| Wallet secret not resolvable | bridge not started, reason shown in the chat |
| `maxSatsPerDay` changed while running | bridge restarted with the new limit |
| Wallet as an env SecretRef instead | resolved; bridge restarted when the reference changed |
## Disclosure
Made by Lampo, which runs lampo.run, the default seller. The plugin works with any L402 seller that publishes a pi402 rate file (`seller` setting). MIT licensed.
integration
Comments
Sign in to leave a comment