Skip to content

Environment Variables

All backend configuration is done through environment variables. The backend reads from backend/.env and backend/.env.local (local overrides).

Frontend variables go in frontend/.env.local.


Backend Variables

Required

VariableDescriptionGet it at
DEEPGRAM_API_KEYSpeech-to-text API keyconsole.deepgram.com
MONGODB_URIMongoDB connection stringLocal, Docker, or Atlas
JWT_SECRETJWT signing key (min 32 chars)Generate a strong random string
ENCRYPTION_KEYAES-256 key for provider credentials (64-char hex)See below

Generate ENCRYPTION_KEY:

bash
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

LLM Provider

At least one LLM provider is needed.

VariableDefaultDescription
GROQ_API_KEYGroq API key. console.groq.com
OPENAI_API_KEYOpenAI API key. platform.openai.com
OLLAMA_BASE_URLhttp://localhost:11434Ollama server URL (free, local)

These are used by the seed-global-providers.sh script to populate global provider credentials.


TTS Provider

VariableDefaultDescription
ELEVENLABS_API_KEYElevenLabs API key. elevenlabs.io
OPENAI_API_KEYAlso used for OpenAI TTS if set
SYSTEM_TTS_CMDSystem command for local TTS
SYSTEM_TTS_EXTOutput file extension for system TTS

If no TTS key is set, Edge TTS is used as a free fallback (dev/testing only).

System TTS examples:

bash
# macOS
SYSTEM_TTS_CMD=say,-o,{out},--data-format=LEF32@22050,{text}
SYSTEM_TTS_EXT=wav

# Linux
SYSTEM_TTS_CMD=espeak,-w,{out},{text}
SYSTEM_TTS_EXT=wav

Server

VariableDefaultDescription
NODE_ENVdevelopmentdevelopment, production, or test
PORT3001Backend HTTP/WS server port
LOG_LEVELPino log level: trace, debug, info, warn, error
CORS_ORIGIN*Allowed CORS origin. Set to your frontend URL in production

Authentication

VariableDefaultDescription
API_KEYSComma-separated legacy API keys (for dev fallback)
JWT_SECRETRequired. Secret for signing JWT tokens (min 32 chars)
JWT_EXPIRES_IN1hJWT token expiry. Examples: 1h, 30m, 7d

Note: API_KEYS is a legacy env-based auth method. In production, use the database-backed API keys created via the dashboard.


Database & Cache

VariableDefaultDescription
MONGODB_URIRequired. MongoDB connection string
MONGODB_MAX_POOL_SIZE100MongoDB connection pool size per instance
REDIS_URLRedis URL for caching, rate limiting, conversation history

Redis is optional. Without it:

  • Rate limiting is in-memory (single instance only)
  • Conversation history is in-memory (lost on restart)
  • Plan cache is in-memory only (no L2 cache)

Security

VariableDefaultDescription
ENCRYPTION_KEYDev fallback64-char hex string (32 bytes) for AES-256-GCM encryption

If not set in development, a deterministic fallback key is derived from a hardcoded string (with a console warning). Always set in production.


Twilio (Phone Calls)

VariableDefaultDescription
TWILIO_APP_URLBackend's public URL (e.g., https://api.voicex.com)

Required for Twilio phone call support. See Twilio Setup.


Frontend Variables

Set in frontend/.env.local.

VariableDefaultDescription
NEXT_PUBLIC_API_URLhttp://localhost:3001/apiBackend API base URL
NEXT_PUBLIC_WS_URLws://localhost:3001/ws/voiceWebSocket voice URL
NEXT_PUBLIC_API_KEYAPI key for WebSocket auth (dev convenience)

Example Configurations

Minimal (Development)

bash
# backend/.env.local
DEEPGRAM_API_KEY=your_deepgram_key
MONGODB_URI=mongodb://localhost:27017/voicex
JWT_SECRET=development_secret_at_least_32_chars
ENCRYPTION_KEY=a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2
GROQ_API_KEY=your_groq_key

Full Production

bash
# backend/.env.local
NODE_ENV=production
PORT=3001

# Required
DEEPGRAM_API_KEY=your_deepgram_key
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/voicex
JWT_SECRET=your_production_min_32_char_secret
ENCRYPTION_KEY=your_64_char_hex_production_key

# LLM + TTS keys (for global providers)
GROQ_API_KEY=your_groq_key
OPENAI_API_KEY=your_openai_key
ELEVENLABS_API_KEY=your_elevenlabs_key

# Infrastructure
REDIS_URL=redis://your-redis:6379
CORS_ORIGIN=https://your-frontend.com

# Twilio (optional)
TWILIO_APP_URL=https://api.your-domain.com

Zero-Cost (Dev)

bash
# backend/.env.local
DEEPGRAM_API_KEY=your_key        # $200 free credit
MONGODB_URI=mongodb://localhost:27017/voicex
JWT_SECRET=at_least_32_characters_long_secret
ENCRYPTION_KEY=<generate_64_hex>
OLLAMA_BASE_URL=http://localhost:11434
# No TTS key → Edge TTS fallback (dev only)

Built with Deepgram, Groq, and ElevenLabs.