Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

feat(openclaw): support configurable gateway providers

JerrettDavis6f500dfa9cf1
diff --git a/plugins/openclaw/README.md b/plugins/openclaw/README.md
index 1b7e30c51..42e0891f6 100644
--- a/plugins/openclaw/README.md
+++ b/plugins/openclaw/README.md
@@ -85,6 +85,25 @@ By default, the plugin also rewrites the built-in `openai-codex` provider base U
This does not replace Headroom's existing Codex routing rules. The proxy already decides between `api.openai.com` and `chatgpt.com/backend-api/codex/responses` based on ChatGPT auth. The plugin change only points OpenClaw's `openai-codex` provider at the active proxy and preserves the rest of the provider config.
+You can also route additional provider ids such as `anthropic`, `copilot`, or `minimax-portal` through the same proxy:
+
+```json
+{
+ "plugins": {
+ "entries": {
+ "headroom": {
+ "enabled": true,
+ "config": {
+ "gatewayProviderIds": ["openai-codex", "anthropic", "copilot", "minimax-portal"]
+ }
+ }
+ }
+ }
+}
+```
+
+When `gatewayProviderIds` is set, it becomes the exact list the plugin rewrites.
+
If you need to disable that behavior:
```json
@@ -165,6 +184,7 @@ Compression is lossless via CCR (Compress-Cache-Retrieve): originals are stored
| `autoStart` | `true` | Auto-start a local `headroom proxy` if not already running (local URLs only; ignored for remote proxies) |
| `startupTimeoutMs` | `20000` | Time to wait for auto-started proxy to become healthy |
| `routeCodexViaProxy` | `true` | Rewrite OpenClaw's built-in `openai-codex` provider to use the active Headroom proxy so upstream Codex requests pass through Headroom. |
+| `gatewayProviderIds` | `[]` | Optional explicit list of OpenClaw provider ids to route through the active Headroom proxy. When set, this overrides the default `openai-codex` routing list. |
## Comparison with lossless-claw
diff --git a/plugins/openclaw/openclaw.plugin.json b/plugins/openclaw/openclaw.plugin.json
index 682dcad5b..da773de0a 100644
--- a/plugins/openclaw/openclaw.plugin.json
+++ b/plugins/openclaw/openclaw.plugin.json
@@ -17,6 +17,10 @@
"routeCodexViaProxy": {
"label": "Route OpenAI Codex Via Headroom",
"help": "When enabled, OpenClaw will use the active Headroom proxy as the upstream base URL for the built-in openai-codex provider so provider traffic flows through Headroom."
+ },
+ "gatewayProviderIds": {
+ "label": "Gateway Provider IDs",
+ "help": "Optional list of OpenClaw provider ids to route through the active Headroom proxy. When set, this overrides the default openai-codex-only routing."
}
},
"configSchema": {
@@ -52,6 +56,13 @@
"routeCodexViaProxy": {
"type": "boolean",
"default": true
+ },
+ "gatewayProviderIds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": []
}
}
},
diff --git a/plugins/openclaw/src/gateway-config.ts b/plugins/openclaw/src/gateway-config.ts
index 1ba00c2bc..0e0b4d3f1 100644
--- a/plugins/openclaw/src/gateway-config.ts
+++ b/plugins/openclaw/src/gateway-config.ts
@@ -3,6 +3,11 @@
export const DEFAULT_GATEWAY_PROVIDER_IDS = ["openai-codex"] as const;
export function resolveGatewayProviderIds(config: Record<string, unknown> | undefined): string[] {
+ const configuredProviderIds = normalizeGatewayProviderIds(config?.gatewayProviderIds);
+ if (configuredProviderIds.length > 0) {
+ return configuredProviderIds;
+ }
+
if (config?.routeCodexViaProxy === false) {
return [];
}
@@ -10,6 +15,31 @@ export function resolveGatewayProviderIds(config: Record<string, unknown> | unde
return [...DEFAULT_GATEWAY_PROVIDER_IDS];
}
+function normalizeGatewayProviderIds(value: unknown): string[] {
+ if (!Array.isArray(value)) {
+ return [];
+ }
+
+ const seen = new Set<string>();
+ const normalized: string[] = [];
+
+ for (const entry of value) {
+ if (typeof entry !== "string") {
+ continue;
+ }
+
+ const providerId = entry.trim();
+ if (!providerId || seen.has(providerId)) {
+ continue;
+ }
+
+ seen.add(providerId);
+ normalized.push(providerId);
+ }
+
+ return normalized;
+}
+
export function applyGatewayProviderBaseUrls<T>(
cfg: T,
proxyUrl: string,
diff --git a/plugins/openclaw/test/gateway-config.test.ts b/plugins/openclaw/test/gateway-config.test.ts
index 746e5454c..d5abdf38a 100644
--- a/plugins/openclaw/test/gateway-config.test.ts
+++ b/plugins/openclaw/test/gateway-config.test.ts
@@ -10,6 +10,22 @@ describe("resolveGatewayProviderIds", () => {
expect(resolveGatewayProviderIds(undefined)).toEqual(["openai-codex"]);
});
+ it("allows an explicit provider list to override the default", () => {
+ expect(
+ resolveGatewayProviderIds({
+ gatewayProviderIds: ["anthropic", "copilot", "minimax-portal"],
+ }),
+ ).toEqual(["anthropic", "copilot", "minimax-portal"]);
+ });
+
+ it("normalizes explicit provider ids", () => {
+ expect(
+ resolveGatewayProviderIds({
+ gatewayProviderIds: [" anthropic ", "", "copilot", "anthropic"],
+ }),
+ ).toEqual(["anthropic", "copilot"]);
+ });
+
it("allows routing to be disabled", () => {
expect(resolveGatewayProviderIds({ routeCodexViaProxy: false })).toEqual([]);
});
@@ -26,6 +42,30 @@ describe("applyGatewayProviderBaseUrls", () => {
});
});
+ it("creates provider configs for multiple configured provider ids", () => {
+ const result = applyGatewayProviderBaseUrls(
+ {},
+ "http://127.0.0.1:8787",
+ ["anthropic", "copilot", "minimax-portal"],
+ );
+
+ expect(result.changed).toBe(true);
+ expect((result.config as any).models.providers).toEqual({
+ anthropic: {
+ baseUrl: "http://127.0.0.1:8787",
+ models: [],
+ },
+ copilot: {
+ baseUrl: "http://127.0.0.1:8787",
+ models: [],
+ },
+ "minimax-portal": {
+ baseUrl: "http://127.0.0.1:8787",
+ models: [],
+ },
+ });
+ });
+
it("preserves existing provider config fields", () => {
const result = applyGatewayProviderBaseUrls(
{