How it works
How it works
Prerequisites
- An Infisical organization where you’re an Agent Vault admin
- Two machines on the same private network, one for the Agent Vault proxy and one for OpenClaw (physical machines, virtual machines, or containers)
- OpenClaw installed on the OpenClaw machine, with the gateway installed as a service (
openclaw onboard --install-daemon) and a messaging platform set up and working with your real API keys - The Infisical CLI 0.43.133 or later installed on the Agent Vault machine (earlier versions don’t apply substitutions)
curlandjqinstalled on the OpenClaw machine
Step 1: List the API keys OpenClaw uses
OpenClaw can keep API keys in three places. Check each one on the OpenClaw machine:- Keys saved during onboarding: onboarding saves model provider keys in OpenClaw’s credential store. Run
openclaw models auth listto list them without printing their values - Channel tokens in OpenClaw’s config: such as
channels.telegram.botTokenfor Telegram ~/.openclaw/.env: if you added keys to this file yourself, list their names without printing their values by runninggrep -o '^[A-Za-z_][A-Za-z0-9_]*=' ~/.openclaw/.env | tr -d '='
How do I know which keys to use?
How do I know which keys to use?
Step 2: Set up Agent Vault
Create an access bundle
First, create an access bundle that holds a service for each API from Step 1.openclaw-gateway, then select Create Access Bundle.- The API expects the key outside a header, such as in the URL path. For example, Telegram’s bot token goes in the URL of every request:
https://api.telegram.org/bot<token>/getUpdates - The API uses more than one key, such as Slack’s bot token and app token (one service can hold a substitution for each key, and an access bundle can’t have two services for the same host)
Enroll a proxy
Next, enroll a proxy on the Agent Vault machine. Every request OpenClaw makes will go through this proxy first. The proxy gets the real credential from the access bundle you just created. It attaches the credential to the request, then forwards the request to the API.- systemd
- Docker
/etc/systemd/system/agent-vault-proxy.service, then enable and start the proxy:enable starts the proxy every time the machine boots, and --now also starts it right away.17323. Make sure the OpenClaw machine can reach that port on the Agent Vault machine’s private address.
Create a session
Finally, create a session for the gateway. This will generate a token that OpenClaw can use to make authenticated requests via the proxy you enrolled.--session-token. The token appears once and can’t be retrieved again.Step 3: Point the OpenClaw gateway at the proxy
Run the commands in this step on the OpenClaw machine. In each command, replace<proxy-host> with the Agent Vault machine’s private address.
Trust the proxy’s certificate
To attach the real credentials, the proxy decrypts the HTTPS requests OpenClaw sends, so OpenClaw has to trust the proxy’s certificate authority. Download the certificate from the proxy:<proxy-host> is the Agent Vault machine’s address, then download the certificate again.
OpenClaw’s gateway runs on Node.js, which only reads its trusted certificates when the service starts, so add the certificate where the gateway service looks for it:
- macOS
- Linux
Replace the API keys with placeholders
Replace each API key you added a service for in Step 2 with a placeholder, wherever OpenClaw keeps it:- For a service that attaches the credential to a header: use any value (the proxy replaces the header with the real credential)
- For a service with a substitution: use the exact placeholder you entered in Replace
openclaw models auth list to find the saved profile, then remove it with openclaw models auth logout <profile-id>. Then create ~/.openclaw/.env, or add to it if it already exists, with the provider’s placeholder. If you added keys to that file yourself, replace their values there too. For example:
openclaw config set. For example:
Route the gateway through the proxy
Set OpenClaw’s proxy URL, replacing<session-token> with the token from Step 2:
Step 4: Verify it works
On the Agent Vault machine, follow the proxy’s logs:- systemd
- Docker
Check the model provider
Send OpenClaw a message through your messaging platform. If OpenClaw replies, both the messaging platform and the model provider received the real credentials, and the proxy logs those requests asbrokered.
Check API calls
To check the credential for another API in your access bundle, ask OpenClaw to call that API. For example, if your access bundle has a GitHub service:
Run curl -sS https://api.github.com/user and show me the output.
GitHub returns your account. If you run the same request in a terminal outside OpenClaw, GitHub responds with a 401.
Revoke or replace the session
To stop OpenClaw from using the real credentials, open Agent Vault in Infisical and go to Sessions. Open the session’s menu and select Revoke Session. The proxy stops attaching credentials within one poll interval, and OpenClaw stops replying because its requests to the model provider fail. To give the gateway a new session, create a session in Infisical. Then, on the OpenClaw machine, runopenclaw config set proxy.proxyUrl again with the new token, and run openclaw gateway restart.
Troubleshooting
To follow the gateway’s logs, runopenclaw logs --follow. To check the gateway’s configuration and service, run openclaw doctor.
Setting up the proxy
The proxy's systemd service fails to start
The proxy's systemd service fails to start
sudo systemctl status agent-vault-proxy shows status=203/EXEC, systemd couldn’t find the Infisical CLI. The unit from the enrollment dialog starts the proxy with /usr/local/bin/infisical, but your CLI may be installed somewhere else.Run which infisical to find your CLI’s path. In /etc/systemd/system/agent-vault-proxy.service, replace /usr/local/bin/infisical at the start of the ExecStart= line with that path, then reload and restart the proxy:Requests that skip the proxy
The proxy logs no requests from OpenClaw
The proxy logs no requests from OpenClaw
--log-level debug added to its command.If the proxy still logs nothing from OpenClaw, the gateway isn’t using the proxy. openclaw config get proxy hides the proxy URL because it contains your session token, so check the value in OpenClaw’s config file instead. This command prints the URL with the session token removed:http://<proxy-host>:17323 with the Agent Vault machine’s address.If the URL is wrong, set it again with openclaw config set proxy.proxyUrl, then run openclaw gateway restart.The messaging platform's requests skip the proxy
The messaging platform's requests skip the proxy
channels.telegram.proxy. If one of these is set, that channel’s requests use it instead of the proxy URL from Step 3. Remove the setting for your channel, then run openclaw gateway restart.Errors from the proxy
407 from the proxy
407 from the proxy
proxy.proxyUrl includes the token as the password, like http://x-agent-vault:<session-token>@<proxy-host>:17323.403 from the proxy
403 from the proxy
- The session was revoked or has expired (check the Sessions page in Infisical, and replace the session if needed)
- Under the proxy’s strict traffic policy, no service in the bundle covers the host OpenClaw called (add a service that does, or use a pass-through service)
- The service covers the host, but doesn’t allow the request’s method or path (check the service’s methods and paths)
Errors in OpenClaw
The gateway logs certificate verification errors
The gateway logs certificate verification errors
NODE_EXTRA_CA_CERTS to an absolute path and that ca.pem isn’t empty, then run systemctl --user daemon-reload and openclaw gateway restart.Authentication error from an upstream API
Authentication error from an upstream API
OpenClaw still uses a real key
OpenClaw still uses a real key
~/.openclaw/.env. Run openclaw models auth list, remove any saved profile for that provider with openclaw models auth logout <profile-id>, then run openclaw gateway restart.A messaging platform rejects the channel's token
A messaging platform rejects the channel's token
getMe returned 404. Set the channel’s token to the exact Replace value with openclaw config set.After a rejected token, OpenClaw stops the channel and doesn’t start it again on its own. Once the placeholder matches, start the channel, replacing <channel> with its name, such as telegram:Channels don't start after several gateway restarts
Channels don't start after several gateway restarts
<channel> with its name:The gateway is stuck waiting for state ownership
The gateway is stuck waiting for state ownership
openclaw tui --local session from the terminal guide. The gateway waits for that process to exit. Quit the terminal session, then run openclaw gateway restart.