Environment variables
Complete reference for Forven's environment variables — startup, paths, the mainnet gate, auth, encryption, AI, the bot sandbox, integrations, backups, launcher flags, and runtime tuning, with meanings and defaults.
Forven reads environment variables to control where it stores data, which ports it binds, whether real-funds (mainnet) orders are ever allowed, how the local HTTP API is secured, and a handful of advanced tuning knobs. This page is the reference: each variable, what it does, and its default.
Most users never set these. Nearly all configuration lives in the app's Settings. Reach for an environment variable only when you need a non-default port or data location, are hardening a deployment beyond localhost, are wiring an integration, or are pinning a value so the UI can't change it.
How variables are resolved
Environment variables sit at the top of Forven's configuration precedence:
env var > in-app settings (KV store) > config.json > built-in defaultSo an environment variable always wins over the same value set in the app or in the configuration file. If a setting "won't stick" in the UI, check for an environment override first.
The backend does not read a .env file by itself; the launcher is what puts variables into its environment:
- macOS / Linux:
start_all.shloads.envfrom the repository root if it exists. Copy.env.exampleto.envand edit it. - Windows:
start_all.ps1reads variables from the shell that runs it. It does not load.env.
On Windows, set a variable for the current PowerShell session:
$env:FORVEN_PORT = "8003"
$env:FORVEN_BIND_HOST = "127.0.0.1"
.\start_all.ps1To make a value stick across sessions on Windows, store it as a user environment variable and open a new terminal:
[Environment]::SetEnvironmentVariable("FORVEN_PORT", "8003", "User")Startup & paths
| Variable | Meaning | Default |
|---|---|---|
FORVEN_HOME | Root directory for app state: forven.db, forven_lab.db, config.json, auth.json, workspace/, and backups/. A legacy .juddex / .judex home is merged in on first run. | ~/.forven |
FORVEN_PORT | Port the FastAPI backend binds. A startup guard detects port collisions. | 8003 |
FRONTEND_PORT | Port for the web UI (start_all.sh only; start_all.ps1 uses 5173 and falls back to a free port if it is taken). | 5173 |
FORVEN_BIND_HOST | Host the backend binds to. FORVEN_HOST is accepted as an alias. See API authentication before changing it. | 127.0.0.1 |
FORVEN_CLIENT_BASE | API base URL used for internal calls and the allowed-origin list. The launchers set it from the port. | http://127.0.0.1:8003 |
FORVEN_DATA_DIR | Directory for OHLCV Parquet files. The other market-data streams (funding, open interest, derivatives, macro) live beside it, in its parent directory. | FORVEN_HOME/data/ohlcv when FORVEN_HOME is set in the environment; otherwise data/ohlcv in the repository |
FORVEN_FRONTEND_DIR | Path to a prebuilt web UI bundle. If set and present, the backend serves it at /. | (unset) |
FORVEN_HOME is the single most important variable: point it at a different directory to run an isolated second instance or to relocate your data. Keep FORVEN_DATA_DIR and FORVEN_HOME consistent — if they disagree, the backend logs a prominent startup error, because enrichment data (funding, open interest, macro) would be read from the wrong place.
Safety: the mainnet gate & execution mode
FORVEN_ALLOW_MAINNET is the one variable that decides whether Forven can ever place a real-funds order. Treat it as the load-bearing safety surface.
| Variable | Meaning | Default |
|---|---|---|
FORVEN_ALLOW_MAINNET | Must be 1 to permit real-funds (mainnet) orders. Default-deny: the exchange layer refuses any order that resolves to mainnet unless it is set. Reduce-only exits and protective stops are always allowed, so you can always get out. There is no UI control for it. | 0 |
FORVEN_EXECUTION_MODE | paper or live. A global label shown in the app, kept for compatibility. It does not decide whether orders are real: a strategy's stage does (see below). Beyond the label it only feeds a few fallbacks, such as the network used when no testnet setting is saved. The in-app and API switch accept paper only. | paper |
FORVEN_ENV | Optional deployment-channel flag. Setting it to beta adds a hard lock that forces the execution mode to paper regardless of other settings. | (unset) |
What actually sends orders to HyperLiquid is a strategy at the Live stage (live_graduated) or a Bot Factory bot armed live. Paper-stage strategies fill locally, inside Forven, and never place an order. Those live orders go to testnet unless you switch Settings → HyperLiquid → Hyperliquid testnet off (a change that needs a typed LIVE to save) and set FORVEN_ALLOW_MAINNET=1.
Paper is the supported mode and the default. There is no supported live / mainnet path. Reaching a real-money order takes a strategy you promote to Live with a typed GO LIVE, the testnet setting turned off, FORVEN_ALLOW_MAINNET=1, and mainnet agent-wallet credentials. It is unsupported and entirely at your own risk. See Execution modes and Going live safely.
The public site sometimes calls the paper stage a candidate strategy; in the app and in these variables it is always paper.
API authentication
Forven's local HTTP API binds to 127.0.0.1 and is unauthenticated unless you set keys. On loopback that is safe for a single user. For anything else, set both keys. See the REST & WebSocket API for endpoint groups and headers.
| Variable | Meaning | Default |
|---|---|---|
FORVEN_API_KEY | If set, every /api/* request must carry this key (header x-api-key or Authorization: Bearer). /api/health, /api/webhooks/*, and the loopback-only /api/shutdown are exempt. | (unset — no auth) |
FORVEN_OPERATOR_KEY | Second, higher-privilege key (header x-operator-key) for operator routes: trading and system controls, promotions, updates, agent tools, MCP servers, and most write operations. | (unset — no auth) |
VITE_FORVEN_API_KEY, VITE_FORVEN_OPERATOR_KEY | The same keys, handed to the web UI so the browser sends them. Set them to match when auth is on. | (unset) |
FORVEN_AUTH_REQUIRED | When true, the backend refuses to start unless both keys are set. | false |
FORVEN_ALLOWED_HOSTS | Extra Host header values to accept (comma-separated) — a DNS-rebinding guard. | loopback names only |
FORVEN_CORS_ORIGINS | Comma-separated origins allowed to call the API from a browser. | the local UI origins |
FORVEN_CSRF_PROTECT | Cross-site request protection for state-changing calls. false is an escape hatch for an unusual front end whose origin cannot be listed in FORVEN_CORS_ORIGINS. | on |
FORVEN_RATE_LIMIT_ENABLED | Per-client request rate limiting (health and WebSocket paths are exempt). | 1 |
FORVEN_RATE_LIMIT_DEFAULT | The default limit. | 600/minute |
Two guards fail closed:
- Non-loopback bind. If
FORVEN_BIND_HOST(orFORVEN_HOST) is anything other than a loopback address, the backend refuses to start unless bothFORVEN_API_KEYandFORVEN_OPERATOR_KEYare set. The API can run code and manage orders; it is never exposed to a network unauthenticated. FORVEN_AUTH_REQUIRED=trueturns the startup warning about missing keys into a hard failure.
$env:FORVEN_API_KEY = "<a-long-random-string>"
$env:FORVEN_OPERATOR_KEY = "<a-different-long-random-string>"
$env:VITE_FORVEN_API_KEY = $env:FORVEN_API_KEY
$env:VITE_FORVEN_OPERATOR_KEY = $env:FORVEN_OPERATOR_KEY
$env:FORVEN_AUTH_REQUIRED = "true"Encryption & secrets
Forven encrypts provider keys and exchange credentials at rest with Fernet symmetric encryption.
| Variable | Meaning | Default |
|---|---|---|
FORVEN_ENCRYPTION_KEY | Explicit Fernet key for secrets. If unset, Forven generates one on first use. | (auto-generated) |
The generated key lives at %LOCALAPPDATA%\Forven\.forven_key on Windows ($XDG_CONFIG_HOME/forven/.forven_key or ~/.config/forven/.forven_key elsewhere) — deliberately outside FORVEN_HOME and outside cloud-synced folders. A key left over in FORVEN_HOME by an older version is migrated there. Forven refuses to generate a fresh key when encrypted data already exists, because a new key would orphan every saved credential.
Your encrypted credentials (auth.json under FORVEN_HOME) and the key that decrypts them live in different places. Back them up together, or set FORVEN_ENCRYPTION_KEY explicitly so the key is reproducible.
HyperLiquid credentials
These supply exchange credentials as a fallback for the encrypted in-app settings. They matter for Live-stage strategies and live-armed bots — paper fills never place an exchange order. Full setup is on the HyperLiquid integration page; keys stay on your machine.
| Variable | Meaning | Default |
|---|---|---|
FORVEN_HL_API_KEY | HyperLiquid API key. | (unset) |
FORVEN_HL_API_SECRET | HyperLiquid API secret (the API/agent wallet's private key). | (unset) |
FORVEN_HL_WALLET_ADDRESS | Your main wallet address. | (unset) |
FORVEN_HL_USE_TESTNET | true for testnet, false for mainnet. | true |
FORVEN_HL_ALLOW_MASTER_KEY | Forven refuses live mainnet trading with a withdrawal-capable master-account key; the safe setup is a separate API/agent wallet. 1 overrides that refusal. Don't. | (unset) |
FORVEN_HL_DISABLE_ENCRYPTION | 1 reads a legacy plaintext settings.json without a key file. | 0 |
FORVEN_HL_CREDS_PATH | Directory of a legacy file-based credential store. | (legacy default) |
Credentials resolve from the encrypted in-app settings (Settings → HyperLiquid) first, then these variables, then the legacy file store. Once the in-app settings exist they win, including the Hyperliquid testnet toggle. Turning testnet off does not permit real-funds orders on its own — FORVEN_ALLOW_MAINNET=1 is the separate, explicit gate.
AI, agents & strategy code
| Variable | Meaning | Default |
|---|---|---|
FORVEN_BACKUP_AI_PROVIDER | Pins the backup provider used when the primary provider's credentials are unusable. none disables it. Normally set in the app. | none |
FORVEN_BACKUP_AI_MODEL | Model id for the backup provider. Empty uses that provider's default. | (empty) |
FORVEN_ENABLE_SHELL_TOOL | Allows agents a raw shell tool. Off by default: subprocess execution mixed with tool calling and web-ingested content is a prompt-injection risk. At your own risk. | 0 |
FORVEN_SHELL_STRICT_ALLOWLIST | When the shell tool is on, restricts it to a vetted list of programs. | 1 |
FORVEN_ISOLATED_STRATEGY_EXEC | Runs your own custom strategies' signal code in the locked-down worker (no database, network, or secrets). Imported strategies always run there. See the safety guard. | off |
FORVEN_ALLOW_LOCAL_MCP | Lets an agent tool server use an http URL on localhost or a private network. Cloud metadata addresses stay blocked. | (unset) |
FORVEN_AGENT_TASK_TIMEOUT_SECONDS | Default timeout for an agent task, when none is saved in settings. | (built in, per task type) |
API keys for model providers are not environment variables — connect providers on the Agents page (Setup → Providers), where they are encrypted at rest.
Bot sandbox (Windows)
| Variable | Meaning | Default |
|---|---|---|
FORVEN_BOT_SANDBOX | On Windows, Bot Factory bots run in a low-integrity sandbox: they can use ~\.forven, the local API and the internet, but cannot write Forven's code or your user profile, or read the master key or .env files. 0 turns the sandbox off. It has no effect on other platforms. | on (Windows) |
Run python -m forven bot-sandbox to prepare and check the sandbox. If it is unusable on your machine, bots start without it and the bot's activity log says why.
Regime gate
The direction × regime gate is normally configured on the risk page or in Settings → Trading → Regime gating. These override it.
| Variable | Meaning | Default |
|---|---|---|
FORVEN_REGIME_GATE_MODE | off, observe (log would-be blocks only), or enforce. | observe |
FORVEN_REGIME_GATE_BLOCK_LONG | Comma-separated regimes in which long entries are vetoed. | TREND_DOWN,HIGH_VOL |
FORVEN_REGIME_GATE_BLOCK_SHORT | Comma-separated regimes in which short entries are vetoed. | (none) |
FORVEN_REGIME_GATE_MIN_CONFIDENCE | Classifier confidence below which a hostile regime is not acted on (0–1). | 0.6 |
Integrations & updates
| Variable | Meaning | Default |
|---|---|---|
DISCORD_TOKEN | Discord bot token. Needed only when START_BOT=1. | (unset) |
DISCORD_WEBHOOK_URL | A Discord webhook URL (https://discord.com/api/webhooks/…). With no bot token, every notification that goes to Discord is posted to that one channel, labelled with where it was meant to go ("Forven · alerts"). Overrides the webhook saved in Settings → Notifications → Discord transport. | (unset) |
POLYGON_API_KEY | Polygon.io key for market data. Overrides the key saved in Settings → System → Data source API keys. | (unset) |
FORVEN_UPDATE_REMOTE | Git remote the in-app updater fast-forwards from. See Updating & backups. | origin |
FORVEN_UPDATE_BRANCH | Branch the in-app updater tracks. | main |
FORVEN_GITHUB_WEBHOOK_SECRET | HMAC secret that enables the /api/webhooks/github auto-pull endpoint. For development setups; leave unset unless you need it. | (unset) |
FORVEN_GITHUB_WEBHOOK_BRANCH | Branch the webhook pulls. | main |
FORVEN_GITHUB_WEBHOOK_REMOTE | Remote the webhook pulls from. | origin |
FORVEN_GITHUB_WEBHOOK_REPO | Path of the local checkout to update. | (unset) |
FORVEN_GITHUB_WEBHOOK_POST_PULL_CMD | Optional command run after a successful pull, such as a service restart. | (unset) |
MCP server
The MCP server is a separate process spawned by your MCP client, so these go in the client's env block, not the backend's environment.
| Variable | Meaning | Default |
|---|---|---|
FORVEN_API_URL | Backend the MCP server calls. | http://127.0.0.1:8003 |
FORVEN_MCP_TIMEOUT | HTTP timeout in seconds. Raise it for slow cold-cache backtests. | 60 |
FORVEN_API_KEY, FORVEN_OPERATOR_KEY | The backend's keys, when auth is on. | (unset) |
Backups & logs
| Variable | Meaning | Default |
|---|---|---|
FORVEN_DB_BACKUP_RETENTION | Snapshots to keep, overriding every per-reason window at once. | 7 daily, 3 pre-migration, 3 for anything else |
FORVEN_DB_BACKUP_MAX_TOTAL_BYTES | Ceiling on the whole backups folder; the oldest snapshots are pruned past it. | the larger of 2 GiB or 6× the database size |
FORVEN_LOG_MAX_BYTES | Size at which a log file rotates. | 52428800 (50 MiB) |
FORVEN_LOG_BACKUP_COUNT | Rotated log files kept alongside the live one. | 3 |
First-run seeding
These control what a fresh FORVEN_HOME is seeded with on its first launch. Most users never set them. See Running from source.
| Variable | Meaning | Default |
|---|---|---|
FORVEN_DEFAULT_ENV | A .env template copied to FORVEN_HOME/.env on first launch, if none exists. | (unset) |
FORVEN_DEFAULT_SEED_DATA | A seed folder (containing ohlcv/<SYMBOL>/*.parquet) copied into FORVEN_HOME/data/ohlcv on first launch, so charts have data immediately. Needs FORVEN_HOME set. The repository's packaging/config/seed_data holds a small BTC and ETH sample at 1h, 4h, and 1d. | (unset) |
FORVEN_DISABLE_CHROMA_IN_PROCESS | Turns off the in-process vector store used for Bot Factory bot memory — a Windows stability workaround. Bot processes set it automatically on Windows; 0 overrides. | (auto on Windows) |
Launcher flags
The launch scripts read these to decide which processes to start. The defaults differ by script, so check which one you run.
| Variable | Meaning | start_all.ps1 | Windows launcher | start_all.sh |
|---|---|---|---|---|
START_BOT | 1 starts the Discord bot. | 0 | 0 | 1 |
START_DAEMON | 1 starts the standalone data/risk daemon. The backend already hosts the daemon loop in-process, so this is optional; a standalone daemon takes over when running. | 0 | 1 | 0 |
FORCE_RESTART | 1 restarts services even if they are healthy. | 0 | 0 | 1 |
BACKEND_WORKERS | Backend worker processes. | 1 | 1 | 2 |
DETACH_SERVICES | 1 keeps services running after the script exits. | 0 | 0 | — |
SHOW_CHILD_WINDOWS | 1 shows each service's console window. | 0 | 0 | — |
START_LAB_WORKER | 1 starts the optional Regime Lab worker. | 0 | 0 | follows FORVEN_ENABLE_REGIME_LAB |
FORVEN_ENABLE_REGIME_LAB | Enables the optional Regime Lab worker and its UI. | 0 | 0 | 0 |
"Windows launcher" means ForvenLauncher.exe / Forven Launcher.vbs (see Installing Forven); start_all.bat uses the same daemon default. START_BOT=1 without DISCORD_TOKEN skips the bot with a warning.
Runtime tuning (advanced)
You rarely need these. They size worker pools and timeouts; the defaults suit a desktop machine, and most have an in-app equivalent set by the throughput preset.
| Variable | Meaning | Default |
|---|---|---|
FORVEN_HEADLESS_AGENT_CONCURRENCY | Agent worker pool size (1–8). | 3 |
FORVEN_HEADLESS_BRAIN_LIMIT | Brain worker task limit (1–8). | 2 |
FORVEN_API_RUNTIME_THREAD_MODE | true runs the scheduler, agent, brain, and daemon loops on their own threads; false runs them as tasks on the event loop. | true |
FORVEN_API_RUNTIME_START_DELAY_SECONDS | Delay before background loops start, to let the database initialize (0–60). | 5.0 |
FORVEN_BACKTEST_PROCESS_ISOLATION | Runs backtests in timed-out subprocesses so a misbehaving strategy can't freeze the backend. | on |
FORVEN_BACKTEST_SUBPROCESS_BUDGET | Pins the process-wide cap on concurrent backtest subprocesses (1–8), overriding the throughput preset. | (from preset) |
FORVEN_CPU_PRIORITY | CPU priority tiers: the live scanner and paper trading keep normal priority, gauntlet steps and research backtest subprocesses run below normal, and the agent task loop lower still. Best effort — if the OS refuses, the work stays at normal priority. off runs everything at normal priority. | on |
FORVEN_GAUNTLET_DRAIN_WORKERS | Pins how many gauntlet jobs drain in parallel (1–8). | (from settings) |
FORVEN_OPTIMIZATION_MAX_WORKERS | Parameter-optimization pool (1–4). | 2 |
FORVEN_ROBUSTNESS_MAX_WORKERS | Robustness-test pool (1–8). | 5 |
FORVEN_ROBUSTNESS_TIMEOUT_SECS | Per-run robustness timeout (min 60). | 600 |
FORVEN_DATA_AUTOBACKFILL | Fetches missing history automatically when a run needs it. | on |
FORVEN_DROPZONE_IDLE_TTL_HOURS | Idle time after which an AI Drop Zone session auto-closes (min 0.25). | 6 |
FORVEN_MAX_UPLOAD_BYTES | Maximum CSV upload size; larger uploads get 413. | 52428800 (50 MiB) |
Verifying your settings
After setting variables, confirm the backend picked them up:
- Start Forven with the launcher (
start_all.ps1on Windows,start_all.shon macOS/Linux). - Open
http://127.0.0.1:8003/api/health— it returns a health payload with no auth required. - Open Diagnostics in the app for the health checks, and look at the control strip at the top of any page: with nothing at the Live stage it reads Mode: PAPER and a TESTNET badge. Live ×N means N strategies or bots can send real orders.
- If you set auth keys, confirm that a request without the key is rejected with
401.
Caveats
- Env always wins. A value set here overrides the same key in the app or
config.json. - Windows doesn't read
.env. Set variables in the shell, or as user environment variables. - Live/mainnet is unsupported. Paper is the supported mode. Setting
FORVEN_ALLOW_MAINNET=1and promoting a strategy to Live is at your own risk. - Secrets and their key can diverge. Back up
FORVEN_HOME/auth.jsontogether with the encryption key, or pin it withFORVEN_ENCRYPTION_KEY. - Exposing the API needs both keys. A non-loopback bind without them refuses to start, by design.
Forven is a research tool. Nothing here is financial advice, paper results are not predictive of live results, and any numbers in the app are illustrative of process — not a forecast of profit.
Related
- Configuration reference —
config.jsonstructure and the full precedence chain - REST & WebSocket API — endpoints, headers, and the auth model these keys back
- Updating & backups — the in-app updater and database snapshots
- Execution modes: paper vs live — what the safety variables actually gate
Configuration reference
Where Forven keeps its configuration, the order settings are resolved in, the pipeline threshold groups (stance preset, quick screen, gauntlet, walk-forward, robustness and deflated Sharpe, the door into paper, the paper pool, paper→live, safety floors, live ramp), and the research, risk and data-engine keys in the settings blob.
REST & WebSocket API
The local Forven HTTP and WebSocket API — base URL, the two authentication keys, the endpoint catalog by area, the live feed, response conventions, and the legacy path shim.