# Env: proxy-router

Source: https://nodedocs.mor.org/reference/env-proxy-router

## Agent Instructions

- Non-browser fetches of page URLs on this site return clean Markdown (not the JS UI). Prefer `https://nodedocs.mor.org/llms-full.txt` for the full corpus, or `https://nodedocs.mor.org/llms.txt` for the index.
- Per-page Markdown is also at `<page-url>.md` (homepage: `https://nodedocs.mor.org/index.md`).
- Docs search MCP: `https://nodedocs.mor.org/mcp` (discovery: `https://nodedocs.mor.org/.well-known/mcp`).
- Never invent contract addresses, chain IDs, token addresses, or live bid/model counts. Cite Networks and tokens; link active.mor.org for live data.
- Never claim Morpheus runs inference — independent providers do. Opening a session escrows MOR; it does not spend it.

The proxy-router is configured through `.env` (or container env vars). This page documents every variable. The canonical `.env.example` lives in the repo at [`proxy-router/.env.example`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/proxy-router/.env.example) and the full annotated dump at [`docs/proxy-router.all.env`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/docs/proxy-router.all.env).

> Defaults below are from the source of truth (`proxy-router/internal/config/config.go`). When in doubt, the source wins.

## Conflicting / overlapping variables — read this first

Several pairs of variables look like they do "the same thing." They don't. The proxy-router resolves each pair with a specific precedence rule, and getting it wrong is a common cause of "I changed the env but nothing happened."

> A non-empty `*_CONTENT` value is written over the file at every process start, in a SecretVM image and in a normal container. An empty value leaves an existing file alone. The same binary serves both deployments; there is no TEE-only path.

`WALLET_PRIVATE_KEY`, `ETH_NODE_ADDRESS`, and `WEB_PUBLIC_URL` are read from the environment on every start and are not stored as these files.

### `COOKIE_FILE_PATH` ↔ `COOKIE_CONTENT`

| Situation | What the proxy-router does |
|-----------|---------------------------|
| `COOKIE_CONTENT` is non-empty | Writes it to the cookie file when the admin password differs, and updates the admin hash in `proxy.conf`. Login checks that hash. |
| `COOKIE_CONTENT` is empty and the cookie file exists | Reads the file. |
| `COOKIE_CONTENT` is empty and the cookie file does not exist | Generates a random 32-char password for `admin`, writes it to the file, and starts. |

Source: [`proxy-router/internal/system/auth.go`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/proxy-router/internal/system/auth.go) (`EnsureConfigFilesExist`).

**Practical implications**

- Paste a new `COOKIE_CONTENT` into SecretVM secrets (or a container env) and restart. The new admin password replaces the stored one.
- A password changed only through `POST /auth/users` is replaced on the next start while `COOKIE_CONTENT` is set.
- With `COOKIE_CONTENT` unset, edit the cookie file or use `POST /auth/users`. That change survives a restart.

### `MODELS_CONFIG_PATH` ↔ `MODELS_CONFIG_CONTENT`

| Situation | What the proxy-router does |
|-----------|---------------------------|
| `MODELS_CONFIG_CONTENT` is non-empty | Writes it over the models file when the bytes differ, then loads that file. |
| `MODELS_CONFIG_CONTENT` is empty and the file exists | Loads the file. |
| `MODELS_CONFIG_CONTENT` is empty and the file does not exist | Logs a warning and starts with an empty model registry. |

Source: [`proxy-router/internal/config/models_config.go`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/proxy-router/internal/config/models_config.go) (`ModelConfigLoader.load`).

**Practical implications**

- Paste updated `MODELS_CONFIG_CONTENT` and restart. The new JSON replaces `models-config.json`.
- With the variable empty, edit the file and restart, or call `POST /config/models/reload`. See [models-config.json](/reference/models-config).

### `AGENT_CONFIG_PATH` ↔ `AGENT_CONFIG_CONTENT`

Same rule as models. A non-empty `AGENT_CONFIG_CONTENT` overwrites the agent file. An empty value loads the existing file. A missing file and an empty value logs a warning and starts with no agents. Source: [`proxy-router/internal/config/agents_config.go`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/proxy-router/internal/config/agents_config.go).

### `RATING_CONFIG_PATH` ↔ `RATING_CONFIG_CONTENT`

Same rule. A non-empty `RATING_CONFIG_CONTENT` overwrites the rating file. An empty value loads the existing file. A missing file and an empty value uses the built-in defaults. Source: [`proxy-router/internal/config/rating_config.go`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/proxy-router/internal/config/rating_config.go).

### `AUTH_CONFIG_FILE_PATH` (no inline twin)

Path to `proxy.conf`, which holds `rpcauth=` and `rpcwhitelist=` lines. **There is no `AUTH_CONFIG_CONTENT` env** — the file is built at runtime by the proxy-router itself when you add users via [`POST /auth/users`](/reference/api-auth#add-or-update-a-user). For TEE / ephemeral deployments, `proxy.conf` is created on first start (with the admin entry derived from the cookie file) and managed via the API afterwards.

### `WALLET_PRIVATE_KEY` ↔ system keychain

| Situation | What the proxy-router does |
|-----------|---------------------------|
| `WALLET_PRIVATE_KEY` is set | Uses it. The keychain is **not** read. |
| `WALLET_PRIVATE_KEY` is unset and the OS supports a keychain (macOS) | Reads / writes the key from the system keychain. |
| Neither | Refuses to start signing transactions; read-only operations still work. |

`APP_RESET_KEYCHAIN=true` wipes the macOS keychain entry on start (use with care).

### `WEB_PUBLIC_URL` fallback

If `WEB_PUBLIC_URL` is unset, the proxy-router synthesizes `http://localhost:<port-from-WEB_ADDRESS>`. For provider deployments where consumers must reach you over the public internet, **always set this explicitly** to your public URL (e.g. `https://provider.example.com`). The TLS-pinning step in TEE attestation reads this URL.

### `ETH_NODE_USE_SUBSCRIPTIONS` ↔ `ETH_NODE_POLLING_INTERVAL`

Not a precedence pair, but easy to misconfigure:

- `ETH_NODE_USE_SUBSCRIPTIONS=true` → expects a **WSS** `ETH_NODE_ADDRESS` (e.g. `wss://...`). Polling interval is irrelevant.
- `ETH_NODE_USE_SUBSCRIPTIONS=false` (default) → expects an **HTTPS** `ETH_NODE_ADDRESS` and uses `ETH_NODE_POLLING_INTERVAL` (default `10` seconds).

Mismatch (e.g. `subscriptions=true` with HTTPS endpoint) makes the node fail to receive blockchain events even though startup may look healthy.

### `PROXY_STORE_CHAT_CONTEXT` is TEE-frozen

In the **`-tee` image** this is hard-coded `false` at build time and **cannot be overridden at runtime**. Setting it in the env has no effect inside a TEE deployment. See [TEE reference](/providers/full/tee-reference).

Storage and forwarding are independent. `PROXY_STORE_CHAT_CONTEXT` persists chats for `/v1/chats`. `PROXY_FORWARD_CHAT_CONTEXT` (default `false`) prepends that stored history onto the next prompt — opt-in for clients that send only the latest turn. OpenAI-compatible clients that already send the full `messages[]` should leave forwarding off.

---

## Application

| Variable | Default | Notes |
|----------|---------|-------|
| `APP_RESET_KEYCHAIN` | `false` | Set `true` to reset the macOS keychain entry on start |
| `AUTH_CONFIG_FILE_PATH` | `./proxy.conf` | Path to the auth config file (no inline twin) |
| `COOKIE_FILE_PATH` | `./.cookie` | Path to admin cookie file |
| `COOKIE_CONTENT` | (unset) | When set, overwrites the cookie file and the admin hash on start. When empty, an existing cookie file is kept. See precedence above. |

## Blockchain

| Variable | Default | Notes |
|----------|---------|-------|
| `ETH_NODE_CHAIN_ID` | `8453` (mainnet) / `84532` (testnet) | BASE chain ID |
| `ETH_NODE_ADDRESS` | (unset, falls back to built-in public RPC round-robin) | RPC endpoint URL (HTTPS or WSS — must match `ETH_NODE_USE_SUBSCRIPTIONS`). **Set explicitly for any real deployment** — the public round-robin fallback is rate-limited and unreliable; missed events break the node silently. The fallback rotates to the next endpoint on rate limits, `401`/`403` WAF pages, `404`/`405`/`410` (a retired service), and on read-only endpoints that answer `eth_sendRawTransaction` with `method is not allowed` — so opening a session works out of the box even when the first public URL refuses writes. |
| `ETH_NODE_LEGACY_TX` | `false` | Set `true` to disable EIP-1559 |
| `ETH_NODE_MAX_GAS_PRICE_GWEI` | `1` | Ceiling for gas-price escalation on the router's own txs (approve, open, close, claim). Fractions allowed; `-1` = unlimited. Applies when unset. See [Transaction escalation](#transaction-escalation-and-the-gas-cap). |
| `BLOCKSCOUT_API_URL` | `https://base.blockscout.com/api/v2` | Block explorer API |
| `EXPLORER_RETRY_DELAY` | `5` | Delay between explorer retries (seconds) |
| `EXPLORER_MAX_RETRIES` | `5` | Max explorer retries |
| `ETH_NODE_USE_SUBSCRIPTIONS` | `false` | `true` to use WSS subscriptions; `false` for HTTP polling |
| `ETH_NODE_POLLING_INTERVAL` | `10` | Polling interval (seconds, only when `ETH_NODE_USE_SUBSCRIPTIONS=false`) |
| `ETH_NODE_MAX_RECONNECTS` | `30` | Max WSS resubscribe attempts (`-1` = unlimited). Retries back off exponentially from 0.5 s to a 30 s cap, and each attempt resubscribes from the block after the last event seen. |

### Transaction escalation and the gas cap

Every transaction the router sends for you (MOR approve, session open, session close, claim) goes through a gas escalator. It submits at the network estimate, waits 20 s, and if the tx is not mined it resubmits the same nonce 15% higher, up to 5 times. Only one of those submissions can ever mine, so you pay one tx fee, not five.

Two limits bound a stuck transaction:

- **Time.** The call waits at most 3 minutes in total. If the attempts run out but a submission is still in the mempool, the router keeps watching it until the window closes and reports success if it lands. If it does not, the error lists the pending tx hashes and says the action may still be mined — check your sessions before retrying.
- **Price.** `ETH_NODE_MAX_GAS_PRICE_GWEI` (default `1`). When the next bid would exceed it, the router stops escalating and returns a "cap exceeded" error instead of chasing a chain that is not including transactions. A later call on the same nonce prices itself above the still-pending tx so it is not rejected as an underpriced replacement, but never above the cap.

Base normally runs at 0.001–0.05 gwei, so 1 gwei is deep-congestion headroom while still refusing to burn ETH on a stalled chain. Raise it only if you are on a chain or during a period where that is a normal price; set `-1` to remove the cap entirely.

## Environment

| Variable | Default | Notes |
|----------|---------|-------|
| `ENVIRONMENT` | `development` | Use `production` in deployments |

## Marketplace

| Variable | Default | Notes |
|----------|---------|-------|
| `DIAMOND_CONTRACT_ADDRESS` | mainnet `0x6aBE1d282f72B474E54527D93b979A4f64d3030a`; testnet `0xA328196f2438DADA5ab729E39388D86896c27c85` | Diamond marketplace contract |
| `MOR_TOKEN_ADDRESS` | mainnet `0x7431aDa8a591C955a994a21710752EF9b882b8e3`; testnet `0x5C80Ddd187054E1E4aBBfFCD750498e81d34FfA3` | MOR ERC-20 token |
| `WALLET_PRIVATE_KEY` | (unset) | Wallet private key. Falls back to system keychain when unset. See precedence above. |

## Logging

| Variable | Default | Notes |
|----------|---------|-------|
| `LOG_COLOR` | `false` | Colored console output |
| `LOG_FOLDER_PATH` | (unset) | If set, also write logs to files in this directory |
| `LOG_IS_PROD` | `false` | Production log format |
| `LOG_JSON` | `false` | JSON-formatted log lines |
| `LOG_LEVEL_APP` | `warn` | App-level log level: `debug` `info` `warn` `error` `dpanic` `panic` `fatal` |
| `LOG_LEVEL_TCP` | `warn` | TCP layer log level |
| `LOG_LEVEL_ETH_RPC` | `warn` | Ethereum RPC log level |
| `LOG_LEVEL_STORAGE` | `warn` | Badger storage log level |

For TEE images logging is **frozen** to production / JSON / minimal at build time — these vars have no effect inside a `-tee` image.

## Network ports & URLs

| Variable | Default | Notes |
|----------|---------|-------|
| `WEB_ADDRESS` | `0.0.0.0:8082` | Bind for the HTTP/Swagger API |
| `WEB_PUBLIC_URL` | `http://localhost:<WEB_ADDRESS port>` | Public-facing URL of the API. **Set explicitly** for any provider that consumers must reach. |
| `PROXY_ADDRESS` | `0.0.0.0:3333` | Bind for the consumer-to-provider TCP proxy |
| `PROXY_CORS_ALLOWED_ORIGINS` | (unset) | Comma-separated list of extra origins allowed to call the HTTP API by browser. Always allowed regardless of this setting: loopback origins, Electron's `null`/`file` origins, and the hosted [MyProvider](/providers/full/myprovider-gui) at `https://myprovider.mor.org`. Set to `*` to allow any origin (not recommended — the API exposes wallet operations such as `/blockchain/send/mor`); needed if you front the API with some other non-localhost browser client. |
| `MORPHEUS_DESKTOP_INSTANCE_TOKEN` | (unset) | Opaque identifier the Desktop app sets so multiple local proxy-router instances can be told apart. When set, it is echoed back on the `X-Morpheus-Instance-Token` header of `GET /healthcheck`. Not needed outside the bundled Desktop app. |

## Proxy state & configs

| Variable | Default | Notes |
|----------|---------|-------|
| `MAX_CACHED_DESTS` | `5` | Max cached provider destinations |
| `PROXY_STORAGE_PATH` | `./data/badger/` | Local Badger / runtime state |
| `PROXY_STORE_CHAT_CONTEXT` | `true` | Persist chat context as one JSON file per chat under `<PROXY_STORAGE_PATH>/chats/`. The directory is kept at mode `0700` and files at `0600` (enforced on every read and write); writes are atomic (temp file + rename), so a crash mid-write cannot truncate a chat. Multimodal turns keep their `multi_content` parts (image / document attachments) in the stored history. **Frozen `false` in `-tee` images.** |
| `PROXY_FORWARD_CHAT_CONTEXT` | `false` | Prepend stored history to prompts. Opt-in for clients that send only the latest turn (the bundled Desktop UI sets it to `true`); leave off for OpenAI-compatible clients that already send the full transcript. |
| `MODELS_CONFIG_PATH` | `./models-config.json` | See [models-config](/reference/models-config). See precedence above. |
| `MODELS_CONFIG_CONTENT` | (unset) | When set, overwrites the models file on start. When empty, an existing file is kept. See precedence above. |
| `AGENT_CONFIG_PATH` | (built-in default) | Local agent registry path |
| `AGENT_CONFIG_CONTENT` | (unset) | When set, overwrites the agent file on start. When empty, an existing file is kept. |
| `RATING_CONFIG_PATH` | `./rating-config.json` | See [rating-config](/reference/rating-config) |
| `RATING_CONFIG_CONTENT` | (unset) | When set, overwrites the rating file on start. When empty, an existing file is kept. |

## Timeouts & retries

| Variable | Default | Notes |
|----------|---------|-------|
| `LLM_TIMEOUT` | `4m` | P-Node → backend LLM timeout (streaming + non-streaming). Go duration (`30s`, `10m`, `1h`). Empty or `0` **falls back to the default** — there is no "no deadline" setting; raise the value for a genuinely slow model. |
| `CNODE_PNODE_TIMEOUT` | `90s` | Per-attempt timeout for C-Node waiting for the P-Node's first response on chat / embeddings / media / audio. Empty or `0` falls back to the default. Total budget ≈ `CNODE_PNODE_TIMEOUT × CNODE_PNODE_MAX_RETRIES`. |
| *(fixed)* | `30s` | Read deadline on the C-Node → P-Node control calls that are not streamed: session handshake (`initiate_session`), provider ping, session reports, agent tool listing / calls, and audio upload chunks. Not configurable. A provider that accepts the TCP connection and then goes silent now fails with `504 provider did not respond within 30s` instead of hanging the request forever. |
| *(fixed)* | `60s` / `30s` | Read deadline on the C-Node → P-Node [video job](/consumers/video) calls: a submit waits up to 60 s for the provider's receipt (the provider gives its vendor 50 s), a status read 30 s. Not configurable. |
| `CNODE_PNODE_MAX_RETRIES` | `3` | Max retries for C-Node → P-Node read timeout (chat / embeddings) |
| `CNODE_PNODE_AUDIO_MAX_RETRIES` | `20` | Max retries for audio transcription / speech routes |

For exact defaults check the source of truth ([`config.go`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/proxy-router/internal/config/config.go)) — these can change between releases as we tune the network.

## Model health self-checks (provider)

On provider nodes the proxy-router periodically probes every model from `models-config.json` that has an **active bid from this provider**: LLM models get a small dynamically generated arithmetic prompt (correctness is graded), embedding models get an embeddings request. Untagged / unknown-type models are probed as LLM unless their tags name image/video/audio/music; a failed guessed probe reports `skipped` (with `errorKind`), not `unhealthy`. STT/TTS and media-tagged models are skipped without a probe, except hosted video models (`apiType` `byteplus-video` or `renderful`), which get a free vendor probe that starts no render. The report covers the whole ecosystem of bids and configured models — active bids whose model is missing from `models-config.json` are flagged as `no_model_configured` (capacity being sold with no backend to serve it). The cached per-model results (on-chain `modelId` and registered model name, `bidId`, status, `errorKind` plus upstream `httpStatus` on failure, `lastHealthy` epoch, latency, prompt correctness — never the private `models-config.json` `apiUrl` or `apiKey`, and `modelName` only inside a hosted video model's job guide, as `video.model_name`) are exposed in the `models` field of `GET /healthcheck`, in the `network.ping` (pong) response on the `:3333` MOR RPC port, and in `POST /proxy/provider/ping`, so consumers can see a provider's model health before opening a session. The [active.mor.org](/ecosystem/active-status) sweep copies these stamps into ALL / ACTIVE / GATEWAY. Full operational guide: [Model health self-report](/providers/full/model-health).

| Variable | Default | Notes |
|----------|---------|-------|
| `MODEL_HEALTH_CHECK_DISABLED` | `false` | Set `true` to disable the loop (the `models` field disappears from `/healthcheck`) |
| `MODEL_HEALTH_CHECK_INTERVAL` | `1h` | How often models are probed; results are cached between runs |
| `MODEL_HEALTH_CHECK_TIMEOUT` | `60s` | Per-model probe timeout |
| `MODEL_HEALTH_CHECK_PROBE_DELAY` | `2s` | Pause between per-model probes so many-model providers don't burst their upstream into a rate limit |
| `MODEL_HEALTH_MAX_CONSECUTIVE_ERRORS` | `3` | Consecutive real-session prompt failures after which the model is reported `unhealthy` (`errorKind: session_errors`) immediately, without waiting for the next scheduled probe |
| `MODEL_API_DETECT_ENABLED` | `true` | Auto-detect the backend API and capabilities of models without `apiStack` (service-endpoint probes, never inference requests, one hop through LiteLLM, plus the offline registry for hostname-recognised vendors); `false` disables all probing and such models report no `api` block unless they declare `capabilities` in `models-config.json`. Per-model budget: 10 s, capped by `MODEL_HEALTH_CHECK_TIMEOUT`. See [models-config.json](/reference/models-config#detection) |
| `MODEL_API_DETECT_TTL` | `MODEL_HEALTH_CHECK_INTERVAL` | How long a detected `api` block, a registry host's model listing and the runtime evidence harvested from the health probe are reused before the backend is probed again; also the once-per-TTL period of the verifier probes below. Default one detection per sweep; minimum `1m` (lower values are raised to it) |
| `MODEL_API_VERIFY_BINDINGS` | `false` | After a healthy LLM probe, one completed run per `MODEL_API_DETECT_TTL` per model (a run that a 401, 402, 403 or 429 stops is resumed once, on the next sweep), send `max_tokens: 1` chat requests that verify the advertised `reasoning.disable` binding (the probe with the binding applied; a `body_param` / `template_kwarg` binding with a fixed value only) and, when `capabilities.tools` is unknown, tool support (the probe with a dummy tool and `tool_choice: "auto"`). Publishes `verified` / `verifiedAt` on the binding, `capabilities.tools`, and drops a binding the backend rejects. Reaches every model with an `api` block: self-hosted engines, hosted vendors and gateways (`openai`, `anthropic`, `openrouter`, `venice`, `litellm`, …), an upstream reached through a gateway and a backend detection could not name; there is no per-backend opt-out. Costs inference tokens, billed per request on a hosted backend |
| `MODEL_API_PROBE_CAPABILITIES` | `false` | On the same schedule, `max_tokens: 1` chat requests with `response_format: json_schema` and with a 1×1 PNG image part (an accepted one publishes `structured ∋ json_schema` / `modalities.input ∋ image`; a refusal publishes nothing), and on vLLM two `POST /v1/chat/completions/render` calls with and without the template reasoning kwarg (differing `token_ids` verify the `reasoning.disable` / `reasoning.enable` template bindings, identical ones refute them). Skipped for a field the block already knows. Reaches every model with an `api` block, like the switch above, and costs inference tokens the same way (billed per request on a hosted backend; the vLLM render calls generate nothing). Up to six extra requests per model per run with both switches on, each paced by `MODEL_HEALTH_CHECK_PROBE_DELAY` and bounded by `MODEL_HEALTH_CHECK_TIMEOUT` |

## Session health policy (consumer)

On consumer nodes, `SESSION_HEALTH_POLICY` controls how strictly the pre-open healthcheck pings gate provider selection when opening a session **by model ID** (the failover loop). Opening by a specific bid ID is unaffected.

| Variable | Default | Notes |
|----------|---------|-------|
| `SESSION_HEALTH_POLICY` | `permissive` | One of `permissive`, `preferred`, `strict` — see below |

| Policy | Behavior |
|--------|----------|
| `permissive` | Default, same as previous releases: skip only providers that self-report the bid's model as `unhealthy`, `tee_unverified`, or `no_model_configured`. Providers with an unknown or missing report are still tried. |
| `preferred` | When at least one provider reports the model `healthy` or `degraded`, only those providers are tried and unknown/missing reports are skipped. When none does, the open falls back to `permissive` so the model is not black-holed. |
| `strict` | Only providers that report the model `healthy` are tried. `degraded` and unknown reports are excluded. |

**Single-bid caveat** (`healthPolicySingleBid: permissive`, fixed): when the hard filters (omitted provider, own bids) leave a single candidate provider for the model, `preferred`/`strict` are forced to `permissive` for that open so the sole provider can still be tried — single-provider models must remain usable.

## Video jobs (consumer)

On consumer nodes the proxy-router asks the session's provider for the status of each running [video job](/consumers/video) until the job ends. Values are Go durations (`10s`, `1m`, `72h`). Empty or `0` uses the default.

| Variable | Default | Notes |
|----------|---------|-------|
| `VIDEO_JOB_POLL_INTERVAL` | `10s` | How often the node asks for a running job's status. Values below `2s` are raised to `2s`. After a failed read the wait doubles, up to 2 minutes. |
| `VIDEO_JOB_MAX_WATCH` | `72h` | How long after the job was created the node keeps asking. After that it marks the job `failed` with error code `watch_timeout`. |

## Gateway managed mode (optional)

Only for consumer nodes that sit **behind a companion gateway** (Uplink or similar) which opens and closes sessions on the node's behalf. Both variables are unset by default and the node behaves exactly as before. Full semantics: [Companion gateway mode](/prosumers/companion-gateway-mode).

| Variable | Default | Notes |
|----------|---------|-------|
| `GATEWAY_JOURNAL_PATH` | *(unset — disabled)* | Directory for per-operation journals. Setting it enables **managed mode**: the `X-Gateway-Operation` idempotency header, `progress` in open/close/withdraw responses, a process-local wallet lock, and the gateway stake formula (supply/budget refresh, +0.01% round-up, 300 s floor). Must be persistent storage; single replica only. |
| `GATEWAY_OWN_CLEANUP` | *(unset)* | Set to `1` **only** when the companion gateway itself closes expired sessions. Suspends the node's native expiry loop after boot-time rehydration. **With no live companion, expired sessions are never auto-closed.** Has no effect unless `GATEWAY_JOURNAL_PATH` is also set. |

## TEE (Phase 1 + Phase 2 attestation)

These are only consulted when at least one model in the marketplace is `tee`-tagged. Otherwise they are unused.

| Variable | Default | Notes |
|----------|---------|-------|
| `TEE_PORTAL_URL` | `https://secretai.scrtlabs.com/api/quote-parse` | SecretAI Portal used to verify raw TDX CPU quotes |
| `TEE_IMAGE_REPO` | `ghcr.io/morpheusais/morpheus-lumerin-node-tee` | GHCR repo where the consumer-side P-Node attestation fetches the signed golden manifest via cosign |
| `ARTIFACT_REGISTRY_URL` | `https://cdn.jsdelivr.net/gh/scrtlabs/secretvm-verify@a5d0d7c21cceef8305dbbb0589cf10dabe7a2047/node/data/tdx.csv` | SecretVM TDX artifact registry CSV (MRTD + RTMR0-2 lookup). Pinned to a [secretvm-verify](https://github.com/scrtlabs/secretvm-verify) commit via jsDelivr because the npm package lags GitHub (0.13.0 lacks v0.0.35). |
| `SEV_ARTIFACT_REGISTRY_URL` | `https://cdn.jsdelivr.net/gh/scrtlabs/secretvm-verify@a5d0d7c21cceef8305dbbb0589cf10dabe7a2047/node/data/sev.json` | SecretVM SEV-SNP artifact registry JSON |
| `ARTIFACT_REGISTRY_REFRESH_INTERVAL` | `1h` | How often the proxy-router re-downloads the artifact registry |

See [TEE overview](/concepts/tee-overview) and [TEE reference](/providers/full/tee-reference).

## IPFS (optional)

The proxy-router talks to a local Kubo API only when you set a real **multiaddr**. Unset `IPFS_MULTADDR` means IPFS is **disabled** — that is the headless default since v7.11. There is **no** `localhost:5001` default (that string is not a multiaddr and used to log ERROR on every boot). The bundled desktop already sets `/ip4/127.0.0.1/tcp/5001` when it runs Kubo.

| Variable | Default | Notes |
|----------|---------|-------|
| `IPFS_MULTADDR` | *(empty — disabled)* | Kubo API multiaddr, e.g. `/ip4/127.0.0.1/tcp/5001`. Invalid values log a warning and disable IPFS. |
| `IPFS_DISABLED` | `false` | Set `true` to force-disable even when `IPFS_MULTADDR` is set. |
| `IPFS_ALLOWED_DIRS` | *(empty)* | OS path list (`:` on Unix, `;` on Windows) of directories that API users **without** the `*` permission may download into via `ipfs_get` and add files from via `ipfs_add`. Unset means those users cannot download or add at all. Users with `*` are never restricted. Downloads never overwrite an existing file. |

## System tuning (optional sysctl tweaks)

These map to OS-level adjustments and only apply when `SYS_ENABLE=true`.

| Variable | Default | Notes |
|----------|---------|-------|
| `SYS_ENABLE` | `false` | Set `true` to apply the values below at startup |
| `SYS_LOCAL_PORT_RANGE` | `1024 65535` | |
| `SYS_NET_DEV_MAX_BACKLOG` | `100000` | |
| `SYS_RLIMIT_HARD` | `524288` | |
| `SYS_RLIMIT_SOFT` | `524288` | |
| `SYS_SOMAXCONN` | `100000` (Linux) / `2048` (Darwin/macOS) | |
| `SYS_TCP_MAX_SYN_BACKLOG` | `100000` | |

## Mainnet vs testnet quick switch

Comment / uncomment the appropriate block in `.env`:

```bash
# MAINNET
ETH_NODE_CHAIN_ID=8453
DIAMOND_CONTRACT_ADDRESS=0x6aBE1d282f72B474E54527D93b979A4f64d3030a
MOR_TOKEN_ADDRESS=0x7431aDa8a591C955a994a21710752EF9b882b8e3
BLOCKSCOUT_API_URL=https://base.blockscout.com/api/v2

# TESTNET (Base Sepolia)
# ETH_NODE_CHAIN_ID=84532
# DIAMOND_CONTRACT_ADDRESS=0xA328196f2438DADA5ab729E39388D86896c27c85
# MOR_TOKEN_ADDRESS=0x5C80Ddd187054E1E4aBBfFCD750498e81d34FfA3
# BLOCKSCOUT_API_URL=https://base-sepolia.blockscout.com/api/v2
```

## Full annotated dump

For the complete annotated reference (every variable, every example value), see [`docs/proxy-router.all.env`](https://github.com/MorpheusAIs/Morpheus-Lumerin-Node/blob/main/docs/proxy-router.all.env) in the repo.
