#how can i change api key?
1 messages · Page 1 of 1 (latest)
@fringe sage
Change it on the gateway host (the machine running openclaw gateway) and then restart the gateway.
Most common way (daemon-safe): edit ~/.openclaw/.env
- Open
~/.openclaw/.envand replace the key, e.g.- Anthropic:
ANTHROPIC_API_KEY=... - OpenAI:
OPENAI_API_KEY=...
- Anthropic:
- Restart the gateway:
openclaw gateway restart - Verify:
openclaw models status # optional (live probe): openclaw models status --probe
Docs: https://docs.openclaw.ai/gateway/authentication
Alternative: re-run the wizard (stores keys for you)
openclaw onboard
# or non-interactive:
openclaw onboard --anthropic-api-key "$ANTHROPIC_API_KEY"
openclaw onboard --openai-api-key "$OPENAI_API_KEY"
Docs: https://docs.openclaw.ai/providers/anthropic and https://docs.openclaw.ai/providers/openai
If you’re in multi-agent / remote mode
- Auth is per-agent (stored under
~/.openclaw/agents/<agentId>/agent/auth-profiles.json) - If your client is “remote”, the key must be changed on the remote gateway machine, not your laptop.
Which provider are you trying to update (Anthropic / OpenAI / OpenRouter / something else)?
How to access that in the ubuntu terminal?
If it says “no such file or directory”, that usually just means the folder/file doesn’t exist yet (that’s fine — you can create it).
On Ubuntu terminal:
mkdir -p ~/.openclaw
nano ~/.openclaw/.env
Then add one line (don’t post your key in Discord):
- For Anthropic:
ANTHROPIC_API_KEY=sk-ant-... - For OpenAI:
OPENAI_API_KEY=sk-...
Save, then restart + verify:
openclaw gateway restart
openclaw models status
If you still can’t find it, you might be:
- editing the wrong machine (remote mode = edit the gateway host), or
- running the gateway under a different user/state dir.
Run these and paste the output (redact any tokens/keys):
I’m here — no need to ping.
If you ran nano ~/.openclaw/.env and it still says “no such file”, paste the exact error text.
Also please run these on the same machine/user that runs the gateway, and paste the output (redact any tokens/keys):
openclaw --version
openclaw gateway status
echo "STATE_DIR=$OPENCLAW_STATE_DIR"
ls -la ~/.openclaw
Most common gotcha: you’re editing ~/.openclaw for your user, but the gateway is running as a different user (or on a different host in remote mode).
openclaw --version
openclaw gateway status
echo "$OPENCLAW_STATE_DIR"
ls -la ~/.openclaw
In Ubuntu terminal, if it says “No such file or directory”, you just need to create the folder/file first:
mkdir -p ~/.openclaw
touch ~/.openclaw/.env
nano ~/.openclaw/.env
Then add your key (example):
- Anthropic:
ANTHROPIC_API_KEY=sk-ant-...
- OpenAI:
OPENAI_API_KEY=sk-...
Save, then restart + verify:
openclaw gateway restart
openclaw models status
If you already did this and still get the error, paste the exact command you typed and the exact error output (don’t paste the actual key). Most common gotcha is a typo in the path (missing the leading . in .openclaw or .env).
On Ubuntu, ~/.openclaw/.env is just a normal hidden file in your home directory. You edit it like any other file.
1) Create the directory + file (if missing), then edit
mkdir -p ~/.openclaw
nano ~/.openclaw/.env
Add your key on its own line (example):
ANTHROPIC_API_KEY=sk-ant-...
orOPENAI_API_KEY=sk-...
Save in nano: Ctrl+O, Enter, then Ctrl+X.
2) Restart gateway + verify
openclaw gateway restart
openclaw models status
If it STILL says “no such file or directory”
Two common causes:
- Typo in the path (must be
.openclawwith the dot):
ls -la ~
ls -la ~/.openclaw
- The gateway is running as a different Linux user (so
~/.openclawis different).
Check which user runs it: