Skip to content

Environment Variables Reference

All environment variables are validated at startup using Zod schemas defined in packages/server/src/config/env.ts. The server will exit with descriptive errors if validation fails.

Core

VariableRequiredDefaultDescription
NODE_ENVNodevelopmentdevelopment, production, or test
PORTNo3000HTTP server listen port
HOSTNo0.0.0.0HTTP server bind address
LOG_LEVELNoinfoerror, warn, info, http, verbose, debug, silly

Database

VariableRequiredDefaultValidation
MONGODB_URINomongodb://localhost:27017/ai-gateway?replicaSet=rs0Must be a valid URL
MONGODB_DB_NAMENoai-gatewayNon-empty string
REDIS_HOSTNolocalhostString
REDIS_PORTNo6379Positive integer
REDIS_PASSWORDProd(empty)Required in production
REDIS_DBNo0Non-negative integer

Authentication

VariableRequiredDefaultValidation
JWT_SECRETYesMinimum 16 characters. Must not contain placeholder values in production.
JWT_REFRESH_SECRETYesMinimum 16 characters. Must not contain placeholder values in production.
JWT_ACCESS_EXPIRYNo15mDuration string (e.g., 15m, 1h)
JWT_REFRESH_EXPIRYNo7dDuration string (e.g., 7d, 30d)
ENCRYPTION_KEYYesExactly 64 hex characters (256-bit AES key). Sequential patterns rejected in production.

Super Admin Seed

Used by pnpm seed to create the initial administrator account.

VariableRequiredDefaultValidation
SUPER_ADMIN_EMAILNoadmin@ai-gateway.localValid email address
SUPER_ADMIN_PASSWORDYes12+ characters, must include uppercase, lowercase, digit, and special character

Semantic Cache

VariableRequiredDefaultDescription
CACHE_EMBEDDING_MODELNonomic-embed-textEmbedding model for cache similarity
CACHE_SIMILARITY_THRESHOLDNo0.96Cosine similarity threshold (0.0-1.0)
CACHE_DEFAULT_TTL_SECONDSNo86400Cache entry TTL in seconds (default: 24 hours)

Rate Limiting

VariableRequiredDefaultDescription
RATE_LIMIT_WINDOW_MSNo60000Window duration in milliseconds
RATE_LIMIT_MAX_PER_WINDOWNo60Max requests per window

CORS and Networking

VariableRequiredDefaultDescription
CORS_ORIGINSNo(empty)Comma-separated allowed origins (each must be a valid URL)
SOCKET_CORS_ORIGINNohttp://localhost:3001Socket.io CORS origin
ADMIN_URLNohttp://localhost:3001Admin dashboard URL
SSO_CALLBACK_BASE_URLNo(optional)Base URL for SSO callback endpoints

Background Workers

VariableRequiredDefaultDescription
BULLMQ_PREFIXNoaigwRedis key prefix for BullMQ queues

S3 Backup

All S3 variables are optional. When not configured, audit log backups are stored locally.

VariableRequiredDefaultDescription
S3_BUCKETNoS3 bucket name
S3_REGIONNous-east-1AWS region
S3_ACCESS_KEY_IDNoAWS access key ID
S3_SECRET_ACCESS_KEYNoAWS secret access key
S3_PREFIXNobackupsKey prefix within the S3 bucket

SIEM Export

All SIEM variables are optional. When not configured, SIEM export is disabled.

VariableRequiredDefaultDescription
SIEM_TYPENoExport type: splunk, elk, or webhook
SIEM_URLNoSIEM endpoint URL
SIEM_TOKENNoAuthentication token
SIEM_BATCH_SIZENo100Events per batch

License (EE)

The Enterprise Edition gates startup on an Ed25519-signed license JWT issued by the 137 & Co. platform. If LICENSE_TOKEN is missing or invalid when NODE_ENV=production, the server exits with process.exit(1) after logging a fatal license error.

VariableRequiredDefaultDescription
LICENSE_TOKENProdEd25519-signed JWT issued by the 137 & Co. platform. Required in production.
LICENSE_PUBLIC_KEYSWhen LICENSE_TOKEN is setOne or more PEM-encoded public keys joined with ;; (the double-semicolon delimiter is used because newlines inside env values are unreliable across shells and Docker).
LICENSE_SERVER_URLNoWhen set, the verifier polls this URL for revocation status. Unset means air-gapped mode (no phone-home).
LICENSE_PHONE_HOME_INTERVAL_MSNo86400000Polling interval (ms) for the revocation check. Default is 24 hours.
LICENSE_GRACE_PERIOD_MSNo604800000How long an expired or revoked token continues to work before the server exits. Default is 7 days.
GATEWYSE_LICENSE_FINGERPRINTNoOptional hardware-fingerprint override. Read directly via process.env in packages/license/src/fingerprint.ts (it is not part of the Zod env schema), because the license verifier runs before env validation. When set, it overrides the auto-derived machine fingerprint used for hardware-bound licenses.

The license verifier runs before the Zod env validator and Winston logger because both depend on environment that has not yet been validated at bootstrap time. For that reason LICENSE_* and GATEWYSE_LICENSE_FINGERPRINT are read straight from process.env and do not appear in the Zod env schema. See packages/server/src/services/license.service.ts for the boot sequence.

API Documentation

VariableRequiredDefaultDescription
ENABLE_SWAGGERNofalseWhen true, exposes the Swagger UI at /docs. In production this is off by default; set to true to enable.

Provider API Keys

Provider API keys are managed through the admin dashboard (or the admin API) and stored per-tenant, encrypted at rest with AES-256-GCM — the gateway resolves them from the database at request time. There is no runtime code path that reads OPENAI_API_KEY, ANTHROPIC_API_KEY, etc. from the environment for live routing.

The variable names below are listed for reference only (e.g. for local development scripts, seeding, or smoke tests); setting them does not configure a provider for the gateway:

Terminal window
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_AI_API_KEY=AIza...
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
GROQ_API_KEY=gsk_...
MISTRAL_API_KEY=...
COHERE_API_KEY=...
DEEPSEEK_API_KEY=...
TOGETHER_API_KEY=...
FIREWORKS_API_KEY=...
PERPLEXITY_API_KEY=pplx-...
AI21_API_KEY=...
HUGGINGFACE_API_KEY=hf_...
XAI_API_KEY=...
CEREBRAS_API_KEY=...
SAMBANOVA_API_KEY=...
REPLICATE_API_TOKEN=r8_...
ELEVENLABS_API_KEY=...
ASSEMBLYAI_API_KEY=...

Production Security Checks

When NODE_ENV=production, the server enforces additional validation at startup:

  1. JWT_SECRET must not contain known placeholder strings
  2. JWT_REFRESH_SECRET must not contain known placeholder strings
  3. ENCRYPTION_KEY must not use sequential hex patterns (e.g., 0123456789abcdef repeated)
  4. REDIS_PASSWORD must be set (non-empty)

If any check fails, the server exits with a descriptive error message.