Skip to content

Configuration

Gatewyse is configured through environment variables. Copy .env.example to .env and customize the values for your deployment.

Terminal window
cp .env.example .env

All environment variables are validated at startup using Zod schemas. The server will exit with a descriptive error if any required variable is missing or invalid.

Core Settings

VariableDefaultDescription
NODE_ENVdevelopmentEnvironment: development, production, or test
PORT3000HTTP server port
HOST0.0.0.0Bind address
LOG_LEVELinfoLog verbosity: error, warn, info, http, verbose, debug, silly

Database

VariableDefaultDescription
MONGODB_URImongodb://localhost:27017/ai-gatewayMongoDB connection string. Single-node by default — see below.
MONGODB_DB_NAMEai-gatewayDatabase name
REDIS_HOSTlocalhostRedis hostname
REDIS_PORT6379Redis port
REDIS_PASSWORD(empty)Redis password (required in production)
REDIS_DB0Redis database number

Does MongoDB need a replica set?

Not for ordinary operation. Everything on the request path stays within a single document, so nothing uses transactions or change streams and the default URI is a plain single-node one — a bare mongod is enough for local development.

There is one exception. Encryption-key rotation re-encrypts several collections and commits them together in a single transaction, because a half-rotated deployment is split across two keys and unrecoverable. Transactions require a replica set, and against a standalone instance the rotation refuses to start rather than proceeding non-atomically — refusing is recoverable, half-rotating is not.

Every shipped Compose file and the Helm chart start MongoDB with --replSet, so this only affects a bare local instance.

Authentication

VariableDefaultDescription
JWT_SECRET(required)JWT signing key, minimum 16 characters
JWT_REFRESH_SECRET(required)Refresh token signing key, minimum 16 characters
JWT_ACCESS_EXPIRY15mAccess token lifetime
JWT_REFRESH_EXPIRY7dRefresh token lifetime
ENCRYPTION_KEY(required)AES-256-GCM key as 64-character hex string for API key encryption

Super Admin Seed

These are used by pnpm seed to create the initial admin account:

VariableDefaultDescription
SUPER_ADMIN_EMAILadmin@ai-gateway.localInitial admin email
SUPER_ADMIN_PASSWORD(required)Must be 12+ chars with uppercase, lowercase, digit, and special character

Semantic Cache

VariableDefaultDescription
CACHE_EMBEDDING_MODELnomic-embed-textModel used for cache similarity matching
CACHE_SIMILARITY_THRESHOLD0.96Minimum cosine similarity for a cache hit (0.0-1.0)
CACHE_DEFAULT_TTL_SECONDS86400Cache entry time-to-live in seconds

Rate Limiting

VariableDefaultDescription
RATE_LIMIT_WINDOW_MS60000Rate limit window in milliseconds
RATE_LIMIT_MAX_PER_WINDOW60Maximum requests per window

CORS and Networking

VariableDefaultDescription
CORS_ORIGINS(empty)Comma-separated list of allowed CORS origins
SOCKET_CORS_ORIGINhttp://localhost:3001Socket.io CORS origin
ADMIN_URLhttp://localhost:3001Admin dashboard URL
SSO_CALLBACK_BASE_URL(optional)Base URL for SSO callbacks

Background Workers

VariableDefaultDescription
BULLMQ_PREFIXaigwBullMQ queue key prefix in Redis

S3 Backup (Optional)

VariableDefaultDescription
S3_BUCKET(optional)S3 bucket name for audit log backups
S3_REGIONus-east-1AWS region
S3_ACCESS_KEY_ID(optional)AWS access key
S3_SECRET_ACCESS_KEY(optional)AWS secret key
S3_PREFIXbackupsKey prefix within the bucket

SIEM Export (Optional)

VariableDefaultDescription
SIEM_TYPE(optional)Export type: splunk, elk, or webhook
SIEM_URL(optional)SIEM endpoint URL
SIEM_TOKEN(optional)Authentication token for SIEM
SIEM_BATCH_SIZE100Number of events per batch export

Provider API Keys

Provider API keys are configured through the admin dashboard (or admin API) and stored in the deployment provider catalogue, encrypted at rest (an organization or department may override an entry with its own credential). The gateway reads them from the database at request time — it does not read OPENAI_API_KEY, ANTHROPIC_API_KEY, etc. from the environment for live routing. Names like the following are reference-only (local dev scripts / smoke tests):

Terminal window
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GROQ_API_KEY=gsk_...

License & API Docs

Enterprise Edition startup is gated on a license (LICENSE_TOKEN, LICENSE_PUBLIC_KEYS, and the optional LICENSE_SERVER_URL / LICENSE_PHONE_HOME_INTERVAL_MS / LICENSE_GRACE_PERIOD_MS / GATEWYSE_LICENSE_FINGERPRINT). Swagger UI at /docs is controlled by ENABLE_SWAGGER (off by default). See Environment Variables for the full reference.

Production Checklist

In production mode (NODE_ENV=production), the server enforces additional security checks:

  • JWT_SECRET and JWT_REFRESH_SECRET must not contain placeholder values
  • ENCRYPTION_KEY must not be a sequential pattern
  • REDIS_PASSWORD must be set
  • SUPER_ADMIN_PASSWORD must meet complexity requirements