Agents & CLIsGuide reviewed 2026-09-13

OpenClaw

Add RouterPlex as a model provider in OpenClaw.

Follow updates Share setup
On this page

Set it up with your coding agent #

Paste your key into the prompt's key field, then copy the prompt into Claude Code, Codex, Cursor, or any coding agent. It configures the tool and keeps testing until a real request goes through RouterPlex, fixing environment problems along the way. Prefer to do it by hand? Follow the manual setup below; your key fills those commands too.

prompt

Optional. It stays in this browser tab and is never saved or sent. No key yet? Create one in guided setup.

Set up OpenClaw on this machine to use RouterPlex, an OpenAI- and Anthropic-compatible AI gateway. Keep working until a real request from OpenClaw succeeds through RouterPlex.
 
My RouterPlex API key: YOUR_ROUTERPLEX_API_KEY
 
Key handling:
- If the key line above is a placeholder rather than a real key (real keys start with sk-), use my ROUTERPLEX_API_KEY environment variable. If that is empty too, ask me for the key once, then continue.
- Store the key only in user-level config or my user environment. Never put it in a project file, never commit it, and do not repeat the full key in your replies.
 
Full guide: https://docs.routerplex.com/openclaw
 
Step 1. Prove the key and the RouterPlex gateway work before changing anything else. Run:
curl -sS https://api.routerplex.com/v1/chat/completions -H "Authorization: Bearer YOUR_ROUTERPLEX_API_KEY" -H "Content-Type: application/json" -d '{"model":"claude-sonnet-4-6","max_tokens":32,"messages":[{"role":"user","content":"Reply with exactly: RouterPlex connected."}]}'
On Windows PowerShell, use curl.exe with the body in a file, or Invoke-RestMethod.
- A reply containing "RouterPlex connected.": go on.
- 401: the key is wrong or revoked. Stop and ask me for a correct key.
- 402: my balance or trial credit is used up. 403: this key reached its own spending limit. Stop and tell me; retrying cannot fix these.
- Network, DNS, TLS, or proxy errors: find and fix the cause (proxy variables, VPN, firewall, system clock, outdated CA certificates), then run it again.
 
Step 2. Configure OpenClaw:
- Run openclaw --version. If OpenClaw is missing, install it with the official installer and run openclaw onboard --install-daemon. It needs Node 24.16+ or 26.1+.
- Merge this into ~/.openclaw/openclaw.json (Windows: %USERPROFILE%\.openclaw\openclaw.json). Keep my existing Gateway authentication, channels, agents, and providers:
 
{
"gateway": {
"mode": "local",
"bind": "loopback"
},
"models": {
"providers": {
"routerplex": {
"baseUrl": "https://api.routerplex.com/v1",
"apiKey": "${ROUTERPLEX_API_KEY}",
"api": "openai-completions",
"models": [
{
"id": "claude-sonnet-4-6",
"name": "claude-sonnet-4-6"
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "routerplex/claude-sonnet-4-6"
},
"models": {
"routerplex/claude-sonnet-4-6": {}
}
}
}
}
 
- A background Gateway does not inherit terminal variables. Save ROUTERPLEX_API_KEY=<key> in OpenClaw's private ~/.openclaw/.env (Windows: %USERPROFILE%\.openclaw\.env) and restrict it to my user (chmod 600 on macOS/Linux).
 
Step 3. Test OpenClaw itself from a new terminal or a restarted app, so you test the saved setup rather than the shell you changed:
Stop the Gateway first (openclaw gateway stop; skip if no service is installed), then run:
openclaw models status --probe --probe-provider routerplex --probe-concurrency 1 --probe-timeout 60000 --probe-max-tokens 256
The probe result must say ok. Start the Gateway again afterwards with openclaw gateway start.
Expected reply: "RouterPlex connected."
 
Step 4. If step 1 works but step 3 fails, the problem is OpenClaw's configuration or environment, not RouterPlex. Check these, fix what is wrong, and repeat step 3:
- The key or base URL is set in one place but not where OpenClaw starts: zsh vs bash startup files, login vs non-login shells, a desktop launcher, a background service, Windows vs WSL, or a remote SSH or container environment.
- Another setting wins: OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_API_BASE, ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL, or a project-level config that overrides the user-level one.
- OpenClaw is outdated, or still needs a full restart to read the new settings.
- If an environment variable cannot be made to reach OpenClaw reliably and OpenClaw accepts a key in its user-level config, put the key there instead.
 
Keep repeating steps 3 and 4 until the test reply comes back. Stop early only for a 401, 402, or 403, or for a step only I can do, such as a click in a settings window or a login. Then tell me exactly what to do, wait for me, and continue testing afterwards.
 
When it works, tell me which files you changed, where the key is stored, and the final test output.

Manual setup #

Configure RouterPlex as an OpenClaw custom provider. macOS, Linux, native Windows, and WSL have supported installation paths. Windows WSL users must run the Linux instructions inside WSL.

1. Install and onboard #

Use OpenClaw's official installer, then follow its local Gateway onboarding. The runtime guide requires Node 24.16+ or Node 26.1+; check node --version and the current Node requirements before upgrading.

macOS / Linux

bash
curl -fsSL https://openclaw.ai/install.sh | bash
openclaw onboard --install-daemon

Windows PowerShell

powershell
iwr -useb https://openclaw.ai/install.ps1 | iex
openclaw onboard --install-daemon

Reopen your terminal after installation. If a Windows npm-installed launcher is blocked as a PowerShell script, use openclaw.cmd for the commands below. During onboarding, choose custom-provider setup for RouterPlex; keep the Gateway local unless you intentionally configure remote access.

2. Merge the provider configuration #

  • macOS/Linux: ~/.openclaw/openclaw.json
  • Native Windows: %USERPROFILE%\.openclaw\openclaw.json
  • WSL: ~/.openclaw/openclaw.json inside the Linux environment.

If you use a custom OpenClaw config or state path, edit that file instead. Preserve existing Gateway authentication, channels, agents, and providers.

json
{
"gateway": {
"mode": "local",
"bind": "loopback"
},
"models": {
"providers": {
"routerplex": {
"baseUrl": "https://api.routerplex.com/v1",
"apiKey": "${ROUTERPLEX_API_KEY}",
"api": "openai-completions",
"models": [
{
"id": "claude-sonnet-4-6",
"name": "claude-sonnet-4-6"
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "routerplex/claude-sonnet-4-6"
},
"models": {
"routerplex/claude-sonnet-4-6": {}
}
}
}
}

openai-completions selects Chat Completions for this integration. RouterPlex also exposes Responses for clients that use it. If agents.defaults.models is present, it acts as an allowlist; include each model you want to select.

3. Make the key available to the Gateway #

For a foreground session, set ROUTERPLEX_API_KEY in the terminal where OpenClaw starts. Replace the placeholder with your key.

macOS/Linux:

bash
export ROUTERPLEX_API_KEY='YOUR_ROUTERPLEX_API_KEY'

Windows PowerShell:

powershell
$env:ROUTERPLEX_API_KEY = 'YOUR_ROUTERPLEX_API_KEY'

A background service does not necessarily inherit your terminal variables. For the default state directory, save ROUTERPLEX_API_KEY=YOUR_ROUTERPLEX_API_KEY in OpenClaw's private ~/.openclaw/.env (Windows: %USERPROFILE%\.openclaw\.env), then restart the Gateway. Keep that file outside source control and restrict access to your user.

4. Verify the provider #

Stop the Gateway before a direct probe, because the probe needs exclusive access to its state directory. Run in the same terminal where you set the key:

text
openclaw gateway stop
openclaw models status --probe --probe-provider routerplex --probe-concurrency 1 --probe-timeout 60000 --probe-max-tokens 256

If no Gateway service is installed, skip the stop command. The probe makes a real model request. Check its result for ok and the matching entry in Usage.

Start the Gateway again with openclaw gateway start if installed as a service, or openclaw gateway run in the configured terminal for a foreground session. Then run openclaw dashboard and send a short message.

A longer walkthrough of the same custom provider is in OpenClaw custom provider.

Official references: installation, custom providers, model probes, environment variables.

OpenClaw · RouterPlex Docs