x402-proxy-openclaw 0.10.9
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/CHANGELOG.md +453 -0
- package/LICENSE +201 -0
- package/README.md +35 -0
- package/dist/commands/wallet.js +149 -0
- package/dist/commands.js +218 -0
- package/dist/defaults.js +129 -0
- package/dist/handler.js +319 -0
- package/dist/history.js +124 -0
- package/dist/lib/config.js +47 -0
- package/dist/lib/debug-log.js +29 -0
- package/dist/lib/derive.js +77 -0
- package/dist/lib/env.js +9 -0
- package/dist/lib/optimized-svm-scheme.js +86 -0
- package/dist/lib/output.js +13 -0
- package/dist/lib/wallet-resolution.js +76 -0
- package/dist/openclaw/plugin.d.ts +15 -0
- package/dist/openclaw/plugin.js +156 -0
- package/dist/openclaw.plugin.json +112 -0
- package/dist/route.js +671 -0
- package/dist/solana.js +93 -0
- package/dist/tools.js +269 -0
- package/dist/wallet.js +15 -0
- package/openclaw.plugin.json +112 -0
- package/package.json +93 -0
- package/skills/SKILL.md +183 -0
- package/skills/references/library.md +85 -0
- package/skills/references/openclaw-plugin.md +145 -0
package/skills/SKILL.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: x402-proxy
|
|
3
|
+
description: Use x402-proxy CLI for consuming and debugging x402 and MPP paid APIs. Use this skill when testing x402/MPP endpoints, configuring MCP payment proxies for AI agents, managing wallets, or scripting paid HTTP requests. Triggers on x402-proxy, npx x402-proxy, x402 endpoint testing, MPP streaming payments, paid API debugging, MCP payment proxy, wallet management, or any mention of auto-paying HTTP 402 responses.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# x402-proxy
|
|
7
|
+
|
|
8
|
+
`curl` for x402 and MPP paid APIs. Auto-pays HTTP 402 responses with USDC on Base, Solana, and [Tempo](https://tempo.xyz/). Supports one-time payments (x402, MPP charge) and pay-per-token streaming (MPP sessions).
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npx x402-proxy -X POST -d '{"ref":"CoinbaseDev"}' https://surf.cascade.fyi/api/v1/twitter/user
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
First run auto-creates a wallet. No setup needed.
|
|
17
|
+
|
|
18
|
+
## HTTP requests
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# GET - body to stdout, payment info to stderr
|
|
22
|
+
npx x402-proxy https://api.example.com/resource
|
|
23
|
+
|
|
24
|
+
# POST with body and headers
|
|
25
|
+
npx x402-proxy --method POST \
|
|
26
|
+
--header "Content-Type: application/json" \
|
|
27
|
+
--body '{"query":"example"}' \
|
|
28
|
+
https://api.example.com/search
|
|
29
|
+
|
|
30
|
+
# Force a specific chain
|
|
31
|
+
npx x402-proxy --network solana https://api.example.com/data
|
|
32
|
+
|
|
33
|
+
# Pipe-safe - only response body on stdout
|
|
34
|
+
npx x402-proxy https://api.example.com/data | jq '.results'
|
|
35
|
+
|
|
36
|
+
# Save response to file
|
|
37
|
+
npx x402-proxy https://api.example.com/data > response.json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Commands
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
x402-proxy <url> # paid HTTP request (default)
|
|
44
|
+
x402-proxy serve # local paid inference proxy server
|
|
45
|
+
x402-proxy claude # run Claude Code through paid local proxy
|
|
46
|
+
x402-proxy mcp <url> # MCP stdio proxy for AI agents
|
|
47
|
+
x402-proxy mcp add <name> <url> # install MCP server into AI client
|
|
48
|
+
x402-proxy setup # wallet onboarding wizard
|
|
49
|
+
x402-proxy setup --force # re-run setup (overwrite existing wallet)
|
|
50
|
+
x402-proxy status # config + wallet + daily spend summary
|
|
51
|
+
x402-proxy config # show current configuration
|
|
52
|
+
x402-proxy config set <key> <value> # set a config value
|
|
53
|
+
x402-proxy config unset <key> # remove a config value
|
|
54
|
+
x402-proxy wallet # show addresses and USDC balances
|
|
55
|
+
x402-proxy wallet history # payment log
|
|
56
|
+
x402-proxy wallet history --limit 5 # last 5 payments
|
|
57
|
+
x402-proxy wallet history --json # machine-readable output
|
|
58
|
+
x402-proxy wallet export-key evm # bare EVM private key to stdout
|
|
59
|
+
x402-proxy wallet export-key solana # bare Solana private key to stdout
|
|
60
|
+
x402-proxy wallet export-key mnemonic # bare mnemonic to stdout
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Fetch flags
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
--method, -X <METHOD> HTTP method (default: GET)
|
|
67
|
+
--header, -H <KEY:VALUE> Add request header (repeatable)
|
|
68
|
+
--body, -d <DATA> Request body (string or @file)
|
|
69
|
+
--network <NETWORK> Force payment chain (base, solana, tempo)
|
|
70
|
+
--protocol <PROTOCOL> Payment protocol (x402, mpp)
|
|
71
|
+
--verbose Show debug details (protocol negotiation, headers, payment flow)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## MCP proxy for AI agents
|
|
75
|
+
|
|
76
|
+
Quick setup (auto-detects installed AI clients):
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
x402-proxy mcp add surf https://surf.cascade.fyi/mcp
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or drop into your client config manually:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"mcpServers": {
|
|
87
|
+
"surf": {
|
|
88
|
+
"command": "npx",
|
|
89
|
+
"args": ["-y", "x402-proxy", "mcp", "https://surf.cascade.fyi/mcp"]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For OpenClaw:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
openclaw mcp set surf '{"command":"npx","args":["-y","x402-proxy","mcp","https://surf.cascade.fyi/mcp"]}'
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The wallet is auto-generated on first run and stored at `~/.config/x402-proxy/wallet.json`. No env vars needed. The proxy intercepts 402 responses, pays automatically, forwards the result. Supports StreamableHTTP and SSE.
|
|
102
|
+
|
|
103
|
+
For non-interactive setup (e.g. automated provisioning):
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npx x402-proxy setup --non-interactive
|
|
107
|
+
# outputs: {"evm":"0x...","solana":"..."}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Wallet & env vars
|
|
111
|
+
|
|
112
|
+
One BIP-39 mnemonic derives both Solana and EVM keypairs. Auto-detects which chain based on USDC balance.
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
X402_PROXY_WALLET_MNEMONIC # BIP-39 mnemonic (derives both chains)
|
|
116
|
+
X402_PROXY_WALLET_EVM_KEY # EVM private key (hex, 0x optional)
|
|
117
|
+
X402_PROXY_WALLET_SOLANA_KEY # Solana private key (base58 or JSON array)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Resolution: flags > env vars > mnemonic env > `~/.config/x402-proxy/wallet.json`
|
|
121
|
+
|
|
122
|
+
Pipe-safe export for scripting:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
MY_KEY=$(npx x402-proxy wallet export-key evm)
|
|
126
|
+
MY_MNEMONIC=$(npx x402-proxy wallet export-key mnemonic)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Config
|
|
130
|
+
|
|
131
|
+
Lives at `~/.config/x402-proxy/` (or `$XDG_CONFIG_HOME/x402-proxy/`):
|
|
132
|
+
|
|
133
|
+
```yaml
|
|
134
|
+
# config.yaml
|
|
135
|
+
defaultNetwork: base # or "solana"
|
|
136
|
+
preferredProtocol: x402 # or "mpp" for Tempo/MPP endpoints
|
|
137
|
+
mppSessionBudget: "1" # max USDC deposit for MPP streaming sessions
|
|
138
|
+
spendLimitDaily: 10 # USDC daily cap
|
|
139
|
+
spendLimitPerTx: 1 # USDC per-request cap
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Also supports JSONC and JSON config files. Wallet stored in `wallet.json` (mode 0600), payments logged to `history.jsonl`.
|
|
143
|
+
|
|
144
|
+
## Testing & debugging x402 services
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Smoke test an endpoint
|
|
148
|
+
npx x402-proxy --verbose https://your-service.com/paid-route
|
|
149
|
+
|
|
150
|
+
# Test both chains
|
|
151
|
+
npx x402-proxy --network base https://your-service.com/route
|
|
152
|
+
npx x402-proxy --network solana https://your-service.com/route
|
|
153
|
+
|
|
154
|
+
# Batch test
|
|
155
|
+
for route in /users/test /tweets/search /v1/crawl; do
|
|
156
|
+
echo "--- $route ---"
|
|
157
|
+
npx x402-proxy "https://your-service.com$route" 2>/dev/null | head -c 200
|
|
158
|
+
echo
|
|
159
|
+
done
|
|
160
|
+
|
|
161
|
+
# Check what you spent
|
|
162
|
+
npx x402-proxy wallet history --limit 5
|
|
163
|
+
npx x402-proxy status
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
stdout = response body, stderr = payment info. Pipes, redirects, and `jq` all work cleanly.
|
|
167
|
+
|
|
168
|
+
## OpenClaw Plugin
|
|
169
|
+
|
|
170
|
+
x402-proxy also ships as a separate [OpenClaw](https://openclaw.dev) plugin package, `x402-proxy-openclaw`, for automatic x402 payments, wallet management, and pay-per-use inference proxying. For full installation, provider/model configuration, and troubleshooting, read `references/openclaw-plugin.md`.
|
|
171
|
+
|
|
172
|
+
Quick install:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
openclaw plugins install x402-proxy-openclaw
|
|
176
|
+
npx x402-proxy setup # creates wallet if needed
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Registers: `x_wallet` tool, `x_request` tool (aliased as `x_balance`/`x_payment`), `/x_wallet` and `/x_send` commands, `/x402-proxy/*` HTTP route for inference proxying.
|
|
180
|
+
|
|
181
|
+
## Library API
|
|
182
|
+
|
|
183
|
+
For programmatic use in Node.js apps, read `references/library.md`.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# x402-proxy Library API
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
npm install x402-proxy
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## Exports
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// Core
|
|
11
|
+
import { createX402ProxyHandler, extractTxSignature } from "x402-proxy";
|
|
12
|
+
import { x402Client } from "x402-proxy";
|
|
13
|
+
|
|
14
|
+
// Chain schemes
|
|
15
|
+
import { ExactEvmScheme, toClientEvmSigner } from "x402-proxy";
|
|
16
|
+
import { ExactSvmScheme } from "x402-proxy";
|
|
17
|
+
|
|
18
|
+
// Wallet loaders
|
|
19
|
+
import { loadEvmWallet, loadSvmWallet } from "x402-proxy";
|
|
20
|
+
|
|
21
|
+
// History
|
|
22
|
+
import { appendHistory, readHistory, calcSpend, explorerUrl, formatTxLine } from "x402-proxy";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## EVM (Base) setup
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { createX402ProxyHandler, x402Client, ExactEvmScheme, toClientEvmSigner } from "x402-proxy";
|
|
29
|
+
import { createWalletClient, http } from "viem";
|
|
30
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
31
|
+
import { base } from "viem/chains";
|
|
32
|
+
|
|
33
|
+
const account = privateKeyToAccount(process.env.EVM_KEY as `0x${string}`);
|
|
34
|
+
const wallet = createWalletClient({ account, chain: base, transport: http() });
|
|
35
|
+
|
|
36
|
+
const client = x402Client(fetch)
|
|
37
|
+
.register(new ExactEvmScheme(toClientEvmSigner(wallet)));
|
|
38
|
+
|
|
39
|
+
const { x402Fetch, shiftPayment } = createX402ProxyHandler({ x402Client: client });
|
|
40
|
+
|
|
41
|
+
const res = await x402Fetch("https://api.example.com/data");
|
|
42
|
+
const body = await res.json();
|
|
43
|
+
const payment = shiftPayment(); // { network, payTo, amount, asset }
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Solana setup
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { createX402ProxyHandler, x402Client, ExactSvmScheme, loadSvmWallet } from "x402-proxy";
|
|
50
|
+
|
|
51
|
+
const signer = loadSvmWallet(process.env.MNEMONIC!);
|
|
52
|
+
const client = x402Client(fetch).register(new ExactSvmScheme(signer));
|
|
53
|
+
const { x402Fetch } = createX402ProxyHandler({ x402Client: client });
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Payment history
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { appendHistory, readHistory, calcSpend } from "x402-proxy";
|
|
60
|
+
|
|
61
|
+
// Read and summarize
|
|
62
|
+
const records = await readHistory("./history.jsonl");
|
|
63
|
+
const { dailyUsd, totalUsd, txCount } = calcSpend(records);
|
|
64
|
+
|
|
65
|
+
// Append a record
|
|
66
|
+
await appendHistory("./history.jsonl", {
|
|
67
|
+
ts: Date.now(),
|
|
68
|
+
status: 200,
|
|
69
|
+
network: "eip155:8453",
|
|
70
|
+
payTo: "0x...",
|
|
71
|
+
amount: "0.001",
|
|
72
|
+
asset: "USDC",
|
|
73
|
+
txId: "0xabc...",
|
|
74
|
+
host: "api.example.com",
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Types
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
type PaymentInfo = { network: string; payTo: string; amount: string; asset: string };
|
|
82
|
+
type X402ProxyOptions = { x402Client: ReturnType<typeof x402Client> };
|
|
83
|
+
type X402ProxyHandler = { x402Fetch: typeof fetch; shiftPayment: () => PaymentInfo | undefined };
|
|
84
|
+
type TxRecord = { ts: number; status: number; network: string; payTo: string; amount: string; asset: string; txId?: string; host: string };
|
|
85
|
+
```
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# OpenClaw Plugin Setup
|
|
2
|
+
|
|
3
|
+
`x402-proxy-openclaw` is the published [OpenClaw](https://openclaw.dev) plugin package for x402-proxy. It gives your gateway automatic x402 and MPP payment, wallet management, and pay-per-use inference proxying via USDC on Solana, Base, and Tempo.
|
|
4
|
+
|
|
5
|
+
## What it registers
|
|
6
|
+
|
|
7
|
+
- **`x_wallet` tool** (alias: `x_balance`) - check wallet readiness, balances, and spend history for x402 and MPP payments
|
|
8
|
+
- **`x_request` tool** (alias: `x_payment`) - call a paid HTTP endpoint with automatic x402 or MPP settlement (params: `url`, `method`, `params`, `headers`, `protocol`)
|
|
9
|
+
- **`/x_wallet` command** - wallet status dashboard, `history [page]`
|
|
10
|
+
- **`/x_send` command** - send USDC with confirmation step (`/x_send <amount|all> <address>`, then `/x_send confirm`)
|
|
11
|
+
- **HTTP route `/x402-proxy/*`** - proxies requests to upstream inference endpoints with payment, tracks token usage and cost
|
|
12
|
+
|
|
13
|
+
## Step 1: Install the plugin
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
openclaw plugins install x402-proxy-openclaw
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This downloads `x402-proxy-openclaw` from npm, validates `openclaw.plugin.json`, and installs the plugin under `~/.openclaw/extensions/x402-proxy/`.
|
|
20
|
+
|
|
21
|
+
## Step 2: Configure wallet
|
|
22
|
+
|
|
23
|
+
The plugin resolves a Solana wallet using the same cascade as the CLI:
|
|
24
|
+
|
|
25
|
+
1. `keypairPath` in plugin config (solana-keygen JSON file)
|
|
26
|
+
2. `X402_PROXY_WALLET_SOLANA_KEY` env var (base58 or JSON array)
|
|
27
|
+
3. `X402_PROXY_WALLET_MNEMONIC` env var (BIP-39, derives both Solana and EVM)
|
|
28
|
+
4. `~/.config/x402-proxy/wallet.json` (auto-created by `npx x402-proxy setup`)
|
|
29
|
+
|
|
30
|
+
Easiest path - run setup first, then the plugin picks up the wallet automatically:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx x402-proxy setup
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or set an explicit keypair in plugin config (step 3).
|
|
37
|
+
|
|
38
|
+
## Step 3: Configure providers and models
|
|
39
|
+
|
|
40
|
+
If you do nothing, the plugin now defaults to:
|
|
41
|
+
|
|
42
|
+
- provider id: `surf`
|
|
43
|
+
- gateway base URL: `/x402-proxy/v1`
|
|
44
|
+
- upstream: `https://surf.cascade.fyi/api/v1/inference`
|
|
45
|
+
- protocol: `mpp`
|
|
46
|
+
|
|
47
|
+
You only need explicit config if you want to override the defaults or supply a custom model catalog.
|
|
48
|
+
|
|
49
|
+
Add the plugin config to your `openclaw.json` (or via `openclaw config edit`):
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"plugins": {
|
|
54
|
+
"entries": {
|
|
55
|
+
"x402-proxy": {
|
|
56
|
+
"config": {
|
|
57
|
+
"providers": {
|
|
58
|
+
"surf-inference": {
|
|
59
|
+
"baseUrl": "/x402-proxy/v1",
|
|
60
|
+
"upstreamUrl": "https://surf.cascade.fyi/api/v1/inference",
|
|
61
|
+
"models": [
|
|
62
|
+
{ "id": "anthropic/claude-opus-4.6", "name": "Claude Opus 4.6", "maxTokens": 200000, "reasoning": true, "input": ["text", "image"], "cost": { "input": 0.015, "output": 0.075, "cacheRead": 0.0015, "cacheWrite": 0.01875 }, "contextWindow": 200000 },
|
|
63
|
+
{ "id": "anthropic/claude-sonnet-4.6", "name": "Claude Sonnet 4.6", "maxTokens": 200000, "reasoning": true, "input": ["text", "image"], "cost": { "input": 0.003, "output": 0.015, "cacheRead": 0.0003, "cacheWrite": 0.00375 }, "contextWindow": 200000 },
|
|
64
|
+
{ "id": "anthropic/claude-opus-4.5", "name": "Claude Opus 4.5", "maxTokens": 200000, "reasoning": true, "input": ["text", "image"], "cost": { "input": 0.015, "output": 0.075, "cacheRead": 0.0015, "cacheWrite": 0.01875 }, "contextWindow": 200000 },
|
|
65
|
+
{ "id": "anthropic/claude-sonnet-4.5", "name": "Claude Sonnet 4.5", "maxTokens": 200000, "reasoning": true, "input": ["text", "image"], "cost": { "input": 0.003, "output": 0.015, "cacheRead": 0.0003, "cacheWrite": 0.00375 }, "contextWindow": 200000 },
|
|
66
|
+
{ "id": "x-ai/grok-4.20-beta", "name": "Grok 4.20 Beta", "maxTokens": 131072, "reasoning": true, "input": ["text"], "cost": { "input": 0.003, "output": 0.015, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
|
|
67
|
+
{ "id": "x-ai/grok-4.20-multi-agent-beta", "name": "Grok 4.20 Multi-Agent", "maxTokens": 131072, "reasoning": true, "input": ["text"], "cost": { "input": 0.003, "output": 0.015, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
|
|
68
|
+
{ "id": "x-ai/grok-4.1-fast", "name": "Grok 4.1 Fast", "maxTokens": 131072, "reasoning": false, "input": ["text"], "cost": { "input": 0.001, "output": 0.005, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
|
|
69
|
+
{ "id": "x-ai/grok-4.20-beta:online", "name": "Grok 4.20 Beta (Online)", "maxTokens": 131072, "reasoning": true, "input": ["text"], "cost": { "input": 0.005, "output": 0.025, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
|
|
70
|
+
{ "id": "x-ai/grok-4.20-multi-agent-beta:online", "name": "Grok 4.20 Multi-Agent (Online)", "maxTokens": 131072, "reasoning": true, "input": ["text"], "cost": { "input": 0.005, "output": 0.025, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
|
|
71
|
+
{ "id": "x-ai/grok-4.1-fast:online", "name": "Grok 4.1 Fast (Online)", "maxTokens": 131072, "reasoning": false, "input": ["text"], "cost": { "input": 0.003, "output": 0.015, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
|
|
72
|
+
{ "id": "minimax/minimax-m2.7", "name": "MiniMax M2.7", "maxTokens": 1000000, "reasoning": false, "input": ["text"], "cost": { "input": 0.001, "output": 0.005, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 1000000 },
|
|
73
|
+
{ "id": "minimax/minimax-m2.5", "name": "MiniMax M2.5", "maxTokens": 1000000, "reasoning": false, "input": ["text"], "cost": { "input": 0.001, "output": 0.005, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 1000000 },
|
|
74
|
+
{ "id": "moonshotai/kimi-k2.5", "name": "Kimi K2.5", "maxTokens": 131072, "reasoning": true, "input": ["text"], "cost": { "input": 0.002, "output": 0.008, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
|
|
75
|
+
{ "id": "z-ai/glm-5", "name": "GLM-5", "maxTokens": 128000, "reasoning": false, "input": ["text"], "cost": { "input": 0.001, "output": 0.005, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 128000 },
|
|
76
|
+
{ "id": "qwen/qwen-2.5-7b-instruct", "name": "Qwen 2.5 7B Instruct", "maxTokens": 32768, "reasoning": false, "input": ["text"], "cost": { "input": 0.0003, "output": 0.001, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 32768 }
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Config fields
|
|
88
|
+
|
|
89
|
+
| Field | Description |
|
|
90
|
+
|-------|-------------|
|
|
91
|
+
| `providers.<name>.baseUrl` | Route path registered in OpenClaw (e.g., `/x402-proxy/v1`) |
|
|
92
|
+
| `providers.<name>.upstreamUrl` | Actual upstream endpoint (e.g., `https://surf.cascade.fyi/api/v1/inference`) |
|
|
93
|
+
| `providers.<name>.models[]` | Model catalog array |
|
|
94
|
+
| `keypairPath` | Optional path to solana-keygen JSON file (overrides wallet resolution) |
|
|
95
|
+
| `rpcUrl` | Solana RPC URL (defaults to mainnet public endpoints with failover) |
|
|
96
|
+
| `dashboardUrl` | URL linked from `/x_wallet` dashboard |
|
|
97
|
+
|
|
98
|
+
### Model entry fields
|
|
99
|
+
|
|
100
|
+
| Field | Type | Description |
|
|
101
|
+
|-------|------|-------------|
|
|
102
|
+
| `id` | string | Model identifier (e.g., `anthropic/claude-opus-4.6`) |
|
|
103
|
+
| `name` | string | Display name |
|
|
104
|
+
| `maxTokens` | number | Max context length |
|
|
105
|
+
| `reasoning` | boolean | Supports extended thinking |
|
|
106
|
+
| `input` | string[] | Input modalities: `["text"]` or `["text", "image"]` |
|
|
107
|
+
| `cost.input` | number | USDC per 1K input tokens |
|
|
108
|
+
| `cost.output` | number | USDC per 1K output tokens |
|
|
109
|
+
| `cost.cacheRead` | number | USDC per 1K cached read tokens |
|
|
110
|
+
| `cost.cacheWrite` | number | USDC per 1K cache write tokens |
|
|
111
|
+
| `contextWindow` | number | Full context window size |
|
|
112
|
+
|
|
113
|
+
## Step 4: Restart gateway and verify
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
openclaw gateway restart
|
|
117
|
+
openclaw models # verify models appear
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## How it works
|
|
121
|
+
|
|
122
|
+
1. Plugin boots, loads wallet via the resolution cascade
|
|
123
|
+
2. Registers each provider from config into OpenClaw's model catalog (API type: `openai-completions`, no auth required)
|
|
124
|
+
3. HTTP route `/x402-proxy/*` intercepts inference requests, strips prefix, proxies to `upstreamUrl`
|
|
125
|
+
4. On 402 response, auto-pays via MPP (Tempo/Base) or x402 (Solana) depending on provider config
|
|
126
|
+
5. SSE streaming responses are parsed for token usage and logged to `~/.config/x402-proxy/history.jsonl`
|
|
127
|
+
6. Tools and command are available to all agents on the gateway
|
|
128
|
+
|
|
129
|
+
## Fetching latest models
|
|
130
|
+
|
|
131
|
+
The model list on `surf.cascade.fyi` changes over time. Fetch the current catalog:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npx x402-proxy --protocol mpp --network solana \
|
|
135
|
+
https://surf.cascade.fyi/api/v1/inference/v1/models
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Then update the `models` array in your plugin config accordingly.
|
|
139
|
+
|
|
140
|
+
## Troubleshooting
|
|
141
|
+
|
|
142
|
+
- **Models don't appear in `openclaw models`** - the plugin uses a `catalog` hook (not `models` field). Make sure you're on x402-proxy >= 0.8.5.
|
|
143
|
+
- **"no wallet found" in logs** - run `npx x402-proxy setup` or set `X402_PROXY_WALLET_MNEMONIC` env var before starting the gateway.
|
|
144
|
+
- **402 errors on inference** - check wallet has USDC balance: use `x_wallet` tool or `npx x402-proxy wallet`.
|
|
145
|
+
- **Gateway cold start slow** - normal on small VMs (~72s). The `x402-wallet` service eagerly loads the wallet during boot.
|