#adding an API to openclaw without it being exposed

1 messages · Page 1 of 1 (latest)

steep turtle
#

I want to add a API key to the enviroment now so that I don't have to worry about my API key being exposed but my openclaw agent will be using this API:
Key REVOSCALE_API_KEY
Value Your RevoScale API key

I want to set that up, but how would I do that

gleaming baneBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

steep turtle
#

@willow echo

willow echoBOT
#

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:

#
  • .env loading does not override an already-set env var (by design). So if you set REVOSCALE_API_KEY somewhere 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 LaunchAgent EnvironmentVariables.
  • 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

  1. Create this file (if it doesn’t exist):
  • ~/.openclaw/.env
  1. Add:
REVOSCALE_API_KEY="PASTE_YOUR_KEY_HERE"
  1. 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

Important notes