L402 (pay in sats)

OpenClaw plugin: models paid per bundle in sats over Lightning (L402), from any Nostr Wallet Connect wallet, within your limits.

Readme

openclaw-l402

An OpenClaw plugin that lets your agent pay for its own model calls in sats. It runs 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), 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

From ClawHub:

sh
openclaw plugins install @lamporun/openclaw-l402 --accept-capabilities

Or straight from this repository: openclaw plugins install git:github.com/lamporun/openclaw-l402@v0.1.3 --accept-capabilities.

The one capability the plugin declares is text inference, for the l402 provider. The code is short (index.js and src/); ClawHub's security audit passed with no findings. Depending on how OpenClaw was installed, the Gateway log may say it can't verify where the plugin came from; the plugin still loads, and openclaw plugins inspect l402 shows its source. 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. 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:

SettingDefaultWhat it does
nwcUrlNWC_URL envYour wallet connection, as a SecretRef
sellerhttps://lampo.run/v1The L402 seller's OpenAI base URL
maxSatsPerPayment1000Refuse any single payment above this
maxSatsPerDay10000Refuse payments once this much was spent today
port8402Loopback port of the bridge
dataDirOpenClaw state dir, plugins/l402Paid tokens and the payment log
receiptstrueCheck 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:

text
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. Routes depend on the liquidity of the moment: Coinos failed to reach lampo.run twice and paid fine later the same day, in 21 seconds. The bridge waits up to 150 seconds for the wallet's answer and never pays twice. 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:

StepResult
Install from ClawHub and from GitHub on fresh installs, wallet in OpenClaw's secret storeinstalled in about 15 s, bridge ready inside the Gateway, wallet named in the log
openclaw models list --provider l402lampo.run's 8 models, free
Agent turn on DeepSeek V4 Flashanswered from an existing bundle in 2 s, receipt verified
GLM 5.3 Flash and Kimi K3 with a 1-sat limitrefused, nothing paid, reason shown in the chat
Wallet secret not resolvablebridge not started, reason shown in the chat
maxSatsPerDay changed while runningbridge restarted with the new limit
Wallet as an env SecretRef insteadresolved; 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.