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-gateway?replicaSet=rs0MongoDB connection string (replica set required)
MONGODB_DB_NAMEai-gatewayDatabase name
REDIS_HOSTlocalhostRedis hostname
REDIS_PORT6379Redis port
REDIS_PASSWORD(empty)Redis password (required in production)
REDIS_DB0Redis database number

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 typically configured through the admin dashboard, where they are encrypted at rest. However, you can also set them as environment variables:

Terminal window
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_AI_API_KEY=...
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
GROQ_API_KEY=gsk_...

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