Skip to main content

Environment variables

OpenClaw reads env vars from the parent process plus:
  • .env from the current working directory (if present)
  • ~/.openclaw/.env (global fallback)
Neither file overrides existing env vars. You can also set inline env vars in config:
If enabled and expected keys aren’t set, OpenClaw runs your login shell and imports only the missing keys:
Env var equivalent: OPENCLAW_LOAD_SHELL_ENV=1. Default timeoutMs: 15000.
Reference env vars in any config string value with ${VAR_NAME}:
Rules:
  • Only uppercase names matched: [A-Z_][A-Z0-9_]*
  • Missing/empty vars stay visibly unresolved, emit a warning, and are unavailable to consumers that require the value
  • Escape with $${VAR} to produce a literal ${VAR} value
  • Works inside $include files
  • Inline substitution: "${BASE}/v1""https://api.example.com/v1"
For fields that support SecretRef objects, you can use:
The env ref above uses the built-in default provider and needs no secrets.providers.default entry unless secrets.defaults.env selects another alias. The same rule applies to store refs and secrets.defaults.store. See Secrets Management for provider precedence and the required file/exec provider configuration. Supported credential paths are listed in SecretRef Credential Surface.
See Environment for full precedence and sources.