Skip to content

Configuration

Configuration lives in two places:

Configuration lives in two places:

  • .env — infrastructure secrets and URLs (see .env.example for the annotated list)
  • Admin → Settings (the SystemSetting table) — integrations configured at runtime. DB values take precedence over env vars for the integrations that support it, so you can rotate a key without a redeploy.

Environment variables

Domain & HTTPS

VariablePurpose
DOMAINPublic hostname (Caddy gets TLS for it automatically)
CADDY_EMAILACME contact for Let's Encrypt
NEXT_PUBLIC_APP_URLApp URL used for payment/ OAuth redirects and auth callbacks
COOKIE_DOMAINShared session cookie domain (e.g. .sleepyai.org) — required for cross-subdomain SSO

Database

VariablePurpose
POSTGRES_DB / POSTGRES_USER / POSTGRES_PASSWORDPostgres credentials
DATABASE_URLApplication connection — through PgBouncer (pgbouncer:6432)
DIRECT_DATABASE_URLDirect Postgres (postgres:5432) — used for migrations and seeding only

Migrations must never go through the pooler. Transaction pooling returns the server connection at the end of each transaction, so Prisma's migration engine can't rely on its session advisory lock. The deploy script uses DIRECT_DATABASE_URL for prisma migrate deploy / db push.

Auth

VariablePurpose
NEXTAUTH_SECRETAuth.js v5 session signing (also derives the key that encrypts API keys and MCP connector headers at rest)
NEXTAUTH_URLLeave empty in production — Auth.js derives the host from the request
AUTH_TRUST_HOSTSet for proxied deployments
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRETGoogle OAuth (also configurable in Admin → Settings → Security)

Routers (upstream AI gateways)

VariablePurpose
OMNIROUTE_MASTER_KEYShared secret for the primary router
OMNIROUTE_PORTPrimary router port
OMNIROUTE_TAGPinned OmniRoute image tag
VANSROUTER_TAGPinned secondary-router image tag (failover)

Both routers pin versioned image tags with pull_policy: always, so a recompose actually lands the new digest instead of reusing a stale cached image. Bump the tag to force a pull.

Upstream provider keys

At least one is required for non-free routes:

OPENAI_API_KEY, ANTHROPIC_API_KEY, DEEPSEEK_API_KEY, GEMINI_API_KEY, GROQ_API_KEY

Payments & email

VariablePurpose
PIPRAPAY_API_KEY / PIPRAPAY_CHECKOUT_URL / PIPRAPAY_VERIFY_URLPayment gateway (DB-stored values win)
BREVO_API_KEY, BREVO_SENDER_* / SMTP_*Transactional email
EMAIL_PROVIDERbrevo or smtp — selects the active email provider

Integrations & ops

VariablePurpose
TELEGRAM_BOT_TOKEN / TELEGRAM_WEBHOOK_SECRET / TELEGRAM_BOT_USERNAMETelegram integration (token is DB-stored)
CRON_SECRETBearer token required by every /api/cron/* endpoint
SEARCH_API_URLSearch sidecar URL used by the built-in web_search connector
DASHBOARD_INTERNAL_URLWhere the chat app reaches the dashboard API
CHAT_MAX_TOOL_ROUNDS / CHAT_MAX_TOOL_CALLSBoot defaults for tool rounds (8) and tool calls (12) per chat message. Prefer Admin → Settings → Chat & Agent, which overrides these
CHAT_TOOL_LOOP_TIMEOUT_MS / CHAT_TURN_TIMEOUT_MSBoot defaults for the tool-loop deadline (240000) and the whole-turn wall clock (420000). Same precedence: the admin setting wins
REQUEST_LOG_BODIES0 by default — set 1 to capture request/response bodies in the admin monitor (see warning below)
API_BACKUP_HOSTHostname of the standalone backup gateway; the same virtual keys work on both URLs
ENABLE_TEST_DEBUG_APIExposes aggregate memory/GC/queue/cache counters at /api/test/debug (no prompts, keys, or rows). Disabled by default.

⚠️ REQUEST_LOG_BODIES=1 stores user prompt and completion content in dashboard process memory and serves it over the admin-only request-log API. Credentials are redacted and bodies are capped at 32 KB, but leave it off unless you're actively debugging.

Runtime (DB-backed) settings

Configure these from Admin → Settings — they take precedence over env vars:

  • PipraPay keys and checkout/verify URLs
  • Brevo/SMTP email settings and the active email provider
  • Telegram bot token and the free-tier group-membership requirement
  • Google OAuth credentials
  • Referral program (enable/disable, rewards, rolling-window cap)
  • Queue settings (concurrency caps, wait timeout, retries)

Chat app settings

The chat container needs:

  • DASHBOARD_INTERNAL_URL — it proxies all generation through the dashboard (it never calls a router directly)
  • COOKIE_DOMAIN — so the login session is shared across subdomains
  • SEARCH_API_URL — the search sidecar for research mode

Chat safety cap

Users get an optional per-conversation chat safety cap, toggled in dashboard Settings. It bounds a single chat turn's spend, independent of the plan windows.

Next: Admin & maintenance