Skip to content

Commit 76c9c91

Browse files
committed
fix(openclaw): fix 404 on inference, add missing models, reduce log spam
- Fix upstream URL: append /v1 to DEFAULT_SURF_UPSTREAM_URL so chat/completions routes correctly to surf.cascade.fyi/api/v1/inference/v1/chat/completions - Add 5 missing models to MODEL_METADATA: z-ai/glm-5.1, x-ai/grok-4.20-multi-agent-beta, and 3 :online variants - Wire fetchUpstreamModels into catalog run for auto-sync with live API - Downgrade startup logs from info to debug to reduce plugin log spam - Update reference doc with all 19 models and correct upstream URL
1 parent 91b2def commit 76c9c91

3 files changed

Lines changed: 68 additions & 14 deletions

File tree

packages/x402-proxy/skills/references/openclaw-plugin.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If you do nothing, the plugin now defaults to:
4141

4242
- provider id: `surf`
4343
- gateway base URL: `/x402-proxy/v1`
44-
- upstream: `https://surf.cascade.fyi/api/v1/inference`
44+
- upstream: `https://surf.cascade.fyi/api/v1/inference/v1`
4545
- protocol: `mpp`
4646

4747
You only need explicit config if you want to override the defaults or supply a custom model catalog.
@@ -57,23 +57,27 @@ Add the plugin config to your `openclaw.json` (or via `openclaw config edit`):
5757
"providers": {
5858
"surf-inference": {
5959
"baseUrl": "/x402-proxy/v1",
60-
"upstreamUrl": "https://surf.cascade.fyi/api/v1/inference",
60+
"upstreamUrl": "https://surf.cascade.fyi/api/v1/inference/v1",
6161
"models": [
6262
{ "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 },
6463
{ "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 },
64+
{ "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 },
6565
{ "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 },
6666
{ "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 },
6767
{ "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 },
6868
{ "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 },
69+
{ "id": "x-ai/grok-4.20-beta:online", "name": "Grok 4.20 Beta (Online)", "maxTokens": 131072, "reasoning": true, "input": ["text"], "cost": { "input": 0.004, "output": 0.015, "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.004, "output": 0.015, "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.001, "output": 0.005, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
7272
{ "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 },
7373
{ "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 },
7474
{ "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 },
7575
{ "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 }
76+
{ "id": "z-ai/glm-5-turbo", "name": "GLM-5 Turbo", "maxTokens": 128000, "reasoning": false, "input": ["text"], "cost": { "input": 0.001, "output": 0.005, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 128000 },
77+
{ "id": "z-ai/glm-5.1", "name": "GLM-5.1", "maxTokens": 202000, "reasoning": true, "input": ["text"], "cost": { "input": 0.002, "output": 0.006, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 202000 },
78+
{ "id": "qwen/qwen-2.5-7b-instruct", "name": "Qwen 2.5 7B Instruct", "maxTokens": 32768, "reasoning": false, "input": ["text"], "cost": { "input": 0.0005, "output": 0.002, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
79+
{ "id": "stepfun/step-3.5-flash", "name": "Step 3.5 Flash", "maxTokens": 131072, "reasoning": false, "input": ["text"], "cost": { "input": 0.001, "output": 0.005, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 },
80+
{ "id": "xiaomi/mimo-v2-pro", "name": "MiMo V2 Pro", "maxTokens": 131072, "reasoning": true, "input": ["text"], "cost": { "input": 0.001, "output": 0.005, "cacheRead": 0, "cacheWrite": 0 }, "contextWindow": 131072 }
7781
]
7882
}
7983
}
@@ -135,10 +139,17 @@ npx x402-proxy --protocol mpp --network solana \
135139
https://surf.cascade.fyi/api/v1/inference/v1/models
136140
```
137141

142+
Or use the catalog auto-sync: the plugin now fetches the live model list from the upstream on each gateway restart. Just restart OpenClaw:
143+
144+
```bash
145+
openclaw gateway restart
146+
```
147+
138148
Then update the `models` array in your plugin config accordingly.
139149

140150
## Troubleshooting
141151

152+
- **HTTP 404 on inference** - check your `upstreamUrl` ends with `/v1` (e.g., `https://surf.cascade.fyi/api/v1/inference/v1`). OpenClaw appends `/chat/completions` directly to the baseUrl, so the `/v1` must be in the upstream path.
142153
- **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.
143154
- **"no wallet found" in logs** - run `npx x402-proxy setup` or set `X402_PROXY_WALLET_MNEMONIC` env var before starting the gateway.
144155
- **402 errors on inference** - check wallet has USDC balance: use `x_wallet` tool or `npx x402-proxy wallet`.

packages/x402-proxy/src/openclaw/defaults.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type ResolvedProviderConfig = {
2121

2222
export const DEFAULT_SURF_PROVIDER_ID = "surf";
2323
export const DEFAULT_SURF_BASE_URL = "/x402-proxy/v1";
24-
export const DEFAULT_SURF_UPSTREAM_URL = "https://surf.cascade.fyi/api/v1/inference";
24+
export const DEFAULT_SURF_UPSTREAM_URL = "https://surf.cascade.fyi/api/v1/inference/v1";
2525
export const DEFAULT_PROVIDER_PROTOCOL: PaymentProtocol = "mpp";
2626
export const DEFAULT_MPP_SESSION_BUDGET = "0.5";
2727

@@ -115,6 +115,46 @@ const MODEL_METADATA: Record<string, Omit<ModelEntry, "provider" | "id">> = {
115115
cost: { input: 0.001, output: 0.005, cacheRead: 0, cacheWrite: 0 },
116116
contextWindow: 128000,
117117
},
118+
"z-ai/glm-5.1": {
119+
name: "GLM-5.1",
120+
maxTokens: 202000,
121+
reasoning: true,
122+
input: ["text"],
123+
cost: { input: 0.002, output: 0.006, cacheRead: 0, cacheWrite: 0 },
124+
contextWindow: 202000,
125+
},
126+
"x-ai/grok-4.20-multi-agent-beta": {
127+
name: "Grok 4.20 Multi-Agent Beta",
128+
maxTokens: 131072,
129+
reasoning: true,
130+
input: ["text"],
131+
cost: { input: 0.003, output: 0.015, cacheRead: 0, cacheWrite: 0 },
132+
contextWindow: 131072,
133+
},
134+
"x-ai/grok-4.1-fast:online": {
135+
name: "Grok 4.1 Fast (Online)",
136+
maxTokens: 131072,
137+
reasoning: false,
138+
input: ["text"],
139+
cost: { input: 0.001, output: 0.005, cacheRead: 0, cacheWrite: 0 },
140+
contextWindow: 131072,
141+
},
142+
"x-ai/grok-4.20-beta:online": {
143+
name: "Grok 4.20 Beta (Online)",
144+
maxTokens: 131072,
145+
reasoning: true,
146+
input: ["text"],
147+
cost: { input: 0.004, output: 0.015, cacheRead: 0, cacheWrite: 0 },
148+
contextWindow: 131072,
149+
},
150+
"x-ai/grok-4.20-multi-agent-beta:online": {
151+
name: "Grok 4.20 Multi-Agent Beta (Online)",
152+
maxTokens: 131072,
153+
reasoning: true,
154+
input: ["text"],
155+
cost: { input: 0.004, output: 0.015, cacheRead: 0, cacheWrite: 0 },
156+
contextWindow: 131072,
157+
},
118158
"qwen/qwen-2.5-7b-instruct": {
119159
name: "Qwen 2.5 7B Instruct",
120160
maxTokens: 32768,
@@ -174,7 +214,7 @@ export async function fetchUpstreamModels(
174214
return modelsCache.models;
175215
}
176216
try {
177-
const res = await globalThis.fetch(`${upstreamUrl}/v1/models`, {
217+
const res = await globalThis.fetch(`${upstreamUrl}/models`, {
178218
signal: AbortSignal.timeout(5000),
179219
});
180220
if (!res.ok) return modelsCache?.models ?? DEFAULT_SURF_MODELS;

packages/x402-proxy/src/openclaw/plugin.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { OptimizedSvmScheme } from "../lib/optimized-svm-scheme.js";
1919
import { resolveWallet } from "../lib/wallet-resolution.js";
2020
import { loadSvmWallet } from "../wallet.js";
2121
import { createSendCommand, createWalletCommand } from "./commands.js";
22-
import { resolveProviders, routePrefixForBaseUrl } from "./defaults.js";
22+
import { fetchUpstreamModels, resolveProviders, routePrefixForBaseUrl } from "./defaults.js";
2323
import { createInferenceProxyRouteHandler } from "./route.js";
2424
import { addressForNetwork, createRequestTool, createWalletTool, SOL_MAINNET } from "./tools.js";
2525

@@ -152,21 +152,24 @@ export function register(api: OpenClawPluginApi): void {
152152
run: async (ctx) => {
153153
const { apiKey } = ctx.resolveProviderApiKey(provider.id);
154154
if (!apiKey) return null;
155+
const models = await fetchUpstreamModels(provider.upstreamUrl).catch(
156+
() => provider.models,
157+
);
155158
return {
156159
provider: {
157160
baseUrl: provider.baseUrl,
158161
api: "openai-completions",
159162
authHeader: false,
160163
apiKey,
161-
models: provider.models,
164+
models,
162165
},
163166
};
164167
},
165168
},
166169
});
167170
}
168171

169-
api.logger.info(
172+
api.logger.debug?.(
170173
`x402-proxy: ${providers.map((provider) => `${provider.id}:${provider.protocol}`).join(", ")} - ${allModels.length} models`,
171174
);
172175

@@ -202,7 +205,7 @@ export function register(api: OpenClawPluginApi): void {
202205
handler,
203206
});
204207
}
205-
api.logger.info(
208+
api.logger.debug?.(
206209
`x402-proxy: HTTP routes ${routePrefixes.join(", ")} registered for ${providers.map((provider) => provider.upstreamUrl).join(", ")}`,
207210
);
208211

@@ -276,7 +279,7 @@ export function register(api: OpenClawPluginApi): void {
276279
mppHandlerRef = null;
277280
}
278281

279-
api.logger.info(
282+
api.logger.debug?.(
280283
`wallets: solana=${solanaWalletAddress ?? "missing"} evm=${evmWalletAddress ?? "missing"}`,
281284
);
282285
} catch (err) {

0 commit comments

Comments
 (0)