Configure environment variables and state paths
configuration & security
// what it does
OpenClaw reads env from the process, ./.env, and ~/.openclaw/.env, and config strings can interpolate ${VAR}. State defaults to ~/.openclaw (override OPENCLAW_STATE_DIR), config to ~/.openclaw/openclaw.json (override OPENCLAW_CONFIG_PATH), and the workspace to ~/.openclaw/workspace.
// shell
$ echo "ANTHROPIC_API_KEY=sk-ant-your-key" >> ~/.openclaw/.env$ export OPENCLAW_STATE_DIR=~/openclaw-work// gotcha
Only uppercase ${VAR_NAME} is substituted; escape a literal with $${VAR}. Keep secrets in .env or an env-sourced token ref, not pasted raw into openclaw.json where a backup archive could leak them.