Configuration
Configuration lives in two places:
Configuration lives in two places:
.env— infrastructure secrets and URLs (see.env.examplefor the annotated list)- Admin → Settings (the
SystemSettingtable) — 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
| Variable | Purpose |
|---|---|
DOMAIN | Public hostname (Caddy gets TLS for it automatically) |
CADDY_EMAIL | ACME contact for Let's Encrypt |
NEXT_PUBLIC_APP_URL | App URL used for payment/ OAuth redirects and auth callbacks |
COOKIE_DOMAIN | Shared session cookie domain (e.g. .sleepyai.org) — required for cross-subdomain SSO |
Database
| Variable | Purpose |
|---|---|
POSTGRES_DB / POSTGRES_USER / POSTGRES_PASSWORD | Postgres credentials |
DATABASE_URL | Application connection — through PgBouncer (pgbouncer:6432) |
DIRECT_DATABASE_URL | Direct 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_URLforprisma migrate deploy/db push.
Auth
| Variable | Purpose |
|---|---|
NEXTAUTH_SECRET | Auth.js v5 session signing (also derives the key that encrypts API keys and MCP connector headers at rest) |
NEXTAUTH_URL | Leave empty in production — Auth.js derives the host from the request |
AUTH_TRUST_HOST | Set for proxied deployments |
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET | Google OAuth (also configurable in Admin → Settings → Security) |
Routers (upstream AI gateways)
| Variable | Purpose |
|---|---|
OMNIROUTE_MASTER_KEY | Shared secret for the primary router |
OMNIROUTE_PORT | Primary router port |
OMNIROUTE_TAG | Pinned OmniRoute image tag |
VANSROUTER_TAG | Pinned 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
| Variable | Purpose |
|---|---|
PIPRAPAY_API_KEY / PIPRAPAY_CHECKOUT_URL / PIPRAPAY_VERIFY_URL | Payment gateway (DB-stored values win) |
BREVO_API_KEY, BREVO_SENDER_* / SMTP_* | Transactional email |
EMAIL_PROVIDER | brevo or smtp — selects the active email provider |
Integrations & ops
| Variable | Purpose |
|---|---|
TELEGRAM_BOT_TOKEN / TELEGRAM_WEBHOOK_SECRET / TELEGRAM_BOT_USERNAME | Telegram integration (token is DB-stored) |
CRON_SECRET | Bearer token required by every /api/cron/* endpoint |
SEARCH_API_URL | Search sidecar URL used by the built-in web_search connector |
DASHBOARD_INTERNAL_URL | Where the chat app reaches the dashboard API |
CHAT_MAX_TOOL_ROUNDS / CHAT_MAX_TOOL_CALLS | Boot 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_MS | Boot defaults for the tool-loop deadline (240000) and the whole-turn wall clock (420000). Same precedence: the admin setting wins |
REQUEST_LOG_BODIES | 0 by default — set 1 to capture request/response bodies in the admin monitor (see warning below) |
API_BACKUP_HOST | Hostname of the standalone backup gateway; the same virtual keys work on both URLs |
ENABLE_TEST_DEBUG_API | Exposes aggregate memory/GC/queue/cache counters at /api/test/debug (no prompts, keys, or rows). Disabled by default. |
⚠️
REQUEST_LOG_BODIES=1stores 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 subdomainsSEARCH_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