Skip to content

Configuration

AiLoom is configured through environment variables. Copy .env.example to .env, fill in the required values, and start the stack with --env-file .env.

Generate the three secrets and the encryption key with:

Terminal window
pnpm secrets:generate

The table is generated from CONFIG_ENV_KEYS; run pnpm docs:config after adding or changing a variable.

Variable Required Description
NODE_ENV no Runtime mode: development, test, or production.
DEMO_MODE no Allows the mock chat provider in a production build for demo and benchmark stacks. Never enable with real users.
PUBLIC_URL yes Public base URL used in emails, the widget snippet, and Caddy.
DATABASE_URL yes PostgreSQL connection string. Compose builds this from POSTGRES_*.
DATABASE_LISTEN_URL no Direct (non-PgBouncer) connection for LISTEN/NOTIFY. Defaults to DATABASE_URL.
DATABASE_SSL no false, true, or require.
DATABASE_SSL_CA no PEM path; when set, database certificates are verified.
AUTH_SECRET yes At least 32 bytes. Signs admin access JWTs; comma-separate for rotation.
ACCESS_TOKEN_TTL_MIN no Admin access token lifetime in minutes.
REFRESH_TOKEN_TTL_DAYS no Refresh token and session lifetime in days.
WIDGET_SECRET yes At least 32 bytes. Signs visitor tokens.
CHALLENGE_SECRET no At least 32 bytes. Signs proof-of-work challenges; required when a bot uses them.
ENCRYPTION_KEYS yes v1:<64 hex>[,v0:<64 hex>]; the highest version encrypts, every entry decrypts.
CRM_OAUTH_CLIENTS no Optional JSON map of OAuth client IDs and secrets for native CRM authorization-code connections.
SIGNUP_MODE no open, invite, or closed.
EMAIL_TRANSPORT no smtp, resend, or none (logs emails).
EMAIL_FROM no Sender address, e.g. Support <support@example.com>. Required when email is enabled.
SMTP_HOST no SMTP server host. Required for EMAIL_TRANSPORT=smtp.
SMTP_PORT no SMTP server port; defaults to 587, or 465 when SMTP_SECURE=true.
SMTP_USER no SMTP login, if the server needs one.
SMTP_PASS no SMTP password.
SMTP_SECURE no true for implicit TLS (usually port 465), false for STARTTLS.
RESEND_API_KEY no Resend API key. Required for EMAIL_TRANSPORT=resend.
STORAGE_DIR no Absolute path for uploaded files; the compose stack mounts /data/files.
MAX_UPLOAD_MB no Largest accepted upload, in megabytes.
CRAWL_MAX_PAGES no Maximum pages fetched for one sitemap source.
CRAWL_RESPECT_ROBOTS no Honour robots.txt while crawling.
CRAWL_USER_AGENT no User-Agent sent by the crawler.
ALLOW_PRIVATE_PROVIDER_URLS no Allow provider base URLs that resolve to private addresses. Off by default for SSRF safety.
PROVIDER_URL_ALLOWLIST no Comma-separated host names, IPs, or CIDR ranges allowed as provider URLs.
PROVIDER_URL_DENYLIST no Comma-separated host names, IPs, or CIDR ranges always blocked.
LOCAL_EMBEDDINGS no Run the built-in ONNX embedding model. Disable below 2 GB RAM.
LOCAL_EMBEDDING_MODEL no Default local embedding model for new bots.
LOG_LEVEL no fatal, error, warn, info, debug, or trace.
RETENTION_CONVERSATIONS_DAYS no Hard-delete closed or AI-owned conversations with no message in this many days; human handoffs are kept. 0 disables deletion.
RETENTION_TRACES_DAYS no Delete generation traces older than this.
RETENTION_SESSIONS_DAYS no Delete revoked sessions older than this.
  • Empty values count as unset. An invalid value stops the process with a list of every problem, without echoing secret values.
  • AUTH_SECRET and ENCRYPTION_KEYS accept comma-separated rotation lists. The first AUTH_SECRET signs and all verify; the highest ENCRYPTION_KEYS version encrypts and all decrypt.
  • Compose-only variables (POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB, HTTP_PORT, HTTPS_PORT, VERSION, IMAGE_OWNER) are documented in .env.example and the self-hosting guide.
  • Provider base URLs are SSRF-checked. See Security before enabling private addresses.

Admins can set optional daily and monthly USD caps in a bot’s Behavior settings. Both use UTC usage totals and prevent new chat generations once the limit is reached. A zero cap disables generation immediately. Caps are preflight checks, so requests already in flight can finish and be included in the recorded spend. The daily cap has no separate alert email; the existing monthly 80% and 100% crossing alerts remain active.

In Models, an admin can optionally choose an economy chat model. AiLoom uses it only for a short, single-part visitor question that passes the conservative deterministic rule. Longer or multi-part messages, questions containing troubleshooting or diagnostic cues, and bots with enabled tools stay on the primary model. The setting is off until an admin chooses an economy model. Provider-error fallback remains a separate reliability setting. Traces show the actual provider/model and whether the economy route was selected. Evaluation runs snapshot the routing model and caps, but their synthetic cases are not blocked by live spend caps. AiLoom does not compare provider pricing when an economy model is selected; confirm the chosen model is cheaper in your provider’s current price list.