Amarnai
Self-Hosting

Configuration

Full environment variable reference for self-hosting Amarnai.

All configuration is done through environment variables in a single .env file at the monorepo root. Copy .env.example as a starting point.

Postgres

VariableDefaultDescription
DATABASE_URLpostgresql://amarnai:amarnai@localhost:5432/amarnaiFull Postgres connection string
POSTGRES_USERamarnaiPostgres username
POSTGRES_PASSWORDamarnaiPostgres password
POSTGRES_DBamarnaiPostgres database name

Redis

VariableDefaultDescription
REDIS_URLredis://localhost:6379Redis connection string

Application

VariableDefaultDescription
API_PORT3001Port the API server listens on
WORKER_PORT3002Port the worker process listens on
INBOX_SYNC_INTERVAL_MS300000How often the worker polls each connected Gmail inbox (milliseconds)
CORS_ORIGINhttp://localhost:3000Allowed CORS origin — set to your web app domain in production

Auth

VariableRequiredDescription
AUTH_SECRETYesRandom secret for NextAuth. Generate with openssl rand -base64 32
AUTH_URLYesPublic URL of the web app (e.g. https://mail.yourdomain.com)
AUTH_GOOGLE_IDYesGoogle OAuth Client ID
AUTH_GOOGLE_SECRETYesGoogle OAuth Client Secret
INTERNAL_API_SECRETYesShared secret for server-action → API calls. Generate with openssl rand -hex 32

Gmail

VariableRequiredDescription
GMAIL_OAUTH_CALLBACK_URLYesRedirect URI registered in Google Cloud Console (e.g. https://mail.yourdomain.com/api/gmail/callback)
GMAIL_TOKEN_ENCRYPTION_KEYYes64-char hex string (32 bytes) for AES-256-GCM encryption of stored refresh tokens. openssl rand -hex 32

AI

VariableDefaultDescription
AI_PROVIDERmockfrontier for production, ollama for local dev, mock for tests
FRONTIER_LLM_PROVIDERopenaiLLM backend (openai or any OpenAI-compatible provider)
FRONTIER_LLM_API_KEYAPI key for the LLM provider
FRONTIER_LLM_MODELgpt-4o-miniModel name
FRONTIER_LLM_BASE_URLOverride base URL for OpenAI-compatible endpoints
EMBEDDING_PROVIDERgeminigemini for production, ollama for local dev
GEMINI_EMBEDDING_API_KEYGoogle AI Studio key for Gemini embeddings
GEMINI_EMBEDDING_MODELtext-embedding-004Gemini embedding model (768-dim)

SMTP

VariableDefaultDescription
EMAIL_FROMSender address for verification and reset emails
SMTP_HOST127.0.0.1SMTP server hostname
SMTP_PORT1025SMTP server port
SMTP_USERSMTP username (required for production)
SMTP_PASSSMTP password (required for production)

Stripe (optional)

Stripe is only needed if you are running the hosted SaaS offering with paid plans. Self-hosters can leave these unset.

VariableDescription
STRIPE_SECRET_KEYStripe secret key
STRIPE_WEBHOOK_SECRETStripe webhook signing secret
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYStripe publishable key
STRIPE_PRICE_PRO_MONTHLYStripe Price ID for the Pro monthly plan
STRIPE_PRICE_PRO_ANNUALStripe Price ID for the Pro annual plan
STRIPE_PRICE_BUSINESS_MONTHLYStripe Price ID for Business monthly
STRIPE_PRICE_BUSINESS_ANNUALStripe Price ID for Business annual

On this page