How does OpenClaw load environment variables

OpenClaw reads env vars from the parent process (shell, launchd/systemd, CI, etc.) and additionally loads:
.env from the current working directory
a global fallback .env from ~/.openclaw/.env (aka $OPENCLAW_STATE_DIR/.env)
Neither .env file overrides existing env vars.
You can also define inline env vars in config (applied only if missing from the process env):
{
env: {
OPENROUTER_API_KEY: "sk-or-...",
vars: { GROQ_API_KEY: "gsk-..." },
},
}
See /environment for full precedence and sources.