#adding an API to openclaw without it being exposed
1 messages · Page 1 of 1 (latest)
@willow echo
To keep a key out of your prompts/config (and avoid accidentally pasting it into Discord), set it as an environment variable that the Gateway process can see.
OpenClaw supports a few sources (highest priority first), but the two most practical are:
Option A (recommended): ~/.openclaw/.env
Create/edit this file:
~/.openclaw/.env
REVOSCALE_API_KEY="your-real-key-here"
Then restart the gateway so it picks it up.
Docs (env precedence + .env locations): https://docs.openclaw.ai/help/environment
Notes:
.envloading does not override an already-set env var (by design). So if you setREVOSCALE_API_KEYsomewhere else and it’s “stuck”, that’s why.
Option B: Set it in the service environment (systemd/launchd/Docker)
If you’re running OpenClaw as a background service, setting it in your shell (export ...) often won’t reach the Gateway.
- macOS launchd: your terminal env usually won’t be inherited; use
~/.openclaw/.env(Option A) or add it to the LaunchAgentEnvironmentVariables. - systemd (Linux): put it in the unit’s Environment/EnvironmentFile.
Using it from an agent/skill
In your agent instructions, just tell it to read REVOSCALE_API_KEY from the environment and never print it. Example: “Call RevoScale using the API key from REVOSCALE_API_KEY.”
If you tell me what OS + how you start OpenClaw (terminal vs service/daemon vs Docker), I can give the exact “put it here” steps for your setup.
Set REVOSCALE_API_KEY on the Gateway’s environment (not inside the chat / not inside your agent prompt).
Easiest + works with services/daemons: ~/.openclaw/.env
- Create this file (if it doesn’t exist):
~/.openclaw/.env
- Add:
REVOSCALE_API_KEY="PASTE_YOUR_KEY_HERE"
- Restart the gateway (whatever method you use to run it) so it reloads env vars.
OpenClaw env loading order + .env locations are documented here:
https://docs.openclaw.ai/help/environment