| summary | Where OpenSoul loads environment variables and the precedence order | |||
|---|---|---|---|---|
| read_when |
|
|||
| title | Environment Variables |
OpenSoul pulls environment variables from multiple sources. The rule is never override existing values.
- Process environment (what the Gateway process already has from the parent shell/daemon).
.envin the current working directory (dotenv default; does not override).- Global
.envat~/.opensoul/.env(aka$OPENSOUL_STATE_DIR/.env; does not override). - Config
envblock in~/.opensoul/opensoul.json(applied only if missing). - Optional login-shell import (
env.shellEnv.enabledorOPENSOUL_LOAD_SHELL_ENV=1), applied only for missing expected keys.
If the config file is missing entirely, step 4 is skipped; shell import still runs if enabled.
Two equivalent ways to set inline env vars (both are non-overriding):
{
env: {
OPENROUTER_API_KEY: "sk-or-...",
vars: {
GROQ_API_KEY: "gsk-...",
},
},
}env.shellEnv runs your login shell and imports only missing expected keys:
{
env: {
shellEnv: {
enabled: true,
timeoutMs: 15000,
},
},
}Env var equivalents:
OPENSOUL_LOAD_SHELL_ENV=1OPENSOUL_SHELL_ENV_TIMEOUT_MS=15000
You can reference env vars directly in config string values using ${VAR_NAME} syntax:
{
models: {
providers: {
"vercel-gateway": {
apiKey: "${VERCEL_GATEWAY_API_KEY}",
},
},
},
}See Configuration: Env var substitution for full details.
These are the recognised OPENSOUL_* environment variables (also shown by opensoul --help):
| Variable | Purpose |
|---|---|
OPENSOUL_GATEWAY_TOKEN |
Gateway authentication token |
OPENSOUL_GATEWAY_PASSWORD |
Gateway password (alternative to token) |
OPENSOUL_GATEWAY_PORT |
Gateway port (default: 18789) |
OPENSOUL_PROFILE |
Named profile (isolates state/config) |
OPENSOUL_STATE_DIR |
Override state directory path |
OPENSOUL_CONFIG_PATH |
Override config file path |
OPENSOUL_GIT_DIR |
Override git checkout directory for dev channel |
OPENSOUL_SKIP_CHANNELS |
Skip loading channel extensions |
OPENSOUL_HIDE_BANNER |
Suppress CLI banner output |
OPENSOUL_NON_INTERACTIVE |
Disable interactive prompts (CI/automation) |
OPENSOUL_DISABLE_LAZY_SUBCOMMANDS |
Force eager command registration |
OPENSOUL_DISABLE_ROUTE_FIRST |
Disable optimised route-first logic |
OPENSOUL_LOAD_SHELL_ENV |
Import missing keys from login shell (see above) |
OPENSOUL_SHELL_ENV_TIMEOUT_MS |
Timeout for shell env import (default: 15000) |