Skip to content

Configuration

import { Aside } from ‘@astrojs/starlight/components’;

OpenSNS is configured through environment variables. This guide covers all available options.

Terminal window
cp .env.example .env
# Edit .env with your settings
Terminal window
# Backend
cp backend/.env.example backend/.env
# Frontend
cp frontend/.env.example frontend/.env.local

These must be set before starting OpenSNS:

VariableDescriptionHow to Generate
JWT_SECRET_KEYSecret for JWT tokens (min 32 chars)openssl rand -hex 32
API_KEY_ENCRYPTION_KEYKey for encrypting stored API keysopenssl rand -hex 32

VariableDescriptionDefault
DATABASE_URLDatabase connection stringsqlite:///./opensns.db

For PostgreSQL (recommended for production):

DATABASE_URL=postgresql://user:password@localhost:5432/opensns

These can be set globally (in .env) or per-user (in Settings UI):

VariableDescription
OPENAI_API_KEYOpenAI API key for GPT models
FAL_KEYFal.ai API key for image/video generation
VariableDescription
HEYGEN_API_KEYHeyGen API key for AI avatar videos
DID_API_KEYD-ID API key for AI avatar videos
SADTALKER_URLSelf-hosted SadTalker endpoint URL

VariableOptionsDefault
DEFAULT_LLM_ENGINEopenai, ollama, mockopenai
DEFAULT_IMAGE_ENGINEfal, flux-pro, comfyuifal
DEFAULT_VIDEO_ENGINEfal-video, runway, comfyui-videofal-video
DEFAULT_UGC_ENGINEheygen, d-id, sadtalkerheygen

For self-hosted AI backends:

VariableDescriptionDefault
OLLAMA_URLOllama API endpointhttp://localhost:11434
COMFYUI_URLComfyUI WebSocket URLhttp://localhost:8188
SADTALKER_URLSadTalker API endpoint(none)

VariableDescriptionDefault
NEXT_PUBLIC_API_URLBackend API URLhttp://localhost:8000
NEXT_PUBLIC_WS_URLWebSocket URL for real-time logsws://localhost:8000

VariableDescriptionDefault
FRONTEND_URLFrontend URL (for email links)http://localhost:3000
CORS_ORIGINSAllowed CORS origins (comma-separated)http://localhost:3000

VariableDescription
PADDLE_API_KEYPaddle API key
PADDLE_WEBHOOK_SECRETPaddle webhook secret
PADDLE_ENVIRONMENTsandbox or production
PADDLE_PRICE_ID_BASICPrice ID for Basic plan
PADDLE_PRICE_ID_PROPrice ID for Pro plan
PADDLE_PRICE_ID_ULTRAPrice ID for Ultra plan
PADDLE_PRICE_ID_CREDITS_50Price ID for 50 credits pack
PADDLE_PRICE_ID_CREDITS_150Price ID for 150 credits pack
PADDLE_PRICE_ID_CREDITS_500Price ID for 500 credits pack

VariableDescription
RESEND_API_KEYResend API key for transactional emails
EMAIL_FROMSender email address (e.g., OpenSNS <noreply@yourdomain.com>)

VariableDescription
GOOGLE_CLIENT_IDGoogle OAuth client ID
GOOGLE_CLIENT_SECRETGoogle OAuth client secret

.env
# ===========================================
# REQUIRED
# ===========================================
JWT_SECRET_KEY=your-64-char-hex-key-from-openssl-rand
API_KEY_ENCRYPTION_KEY=your-64-char-hex-key-from-openssl-rand
# ===========================================
# AI ENGINES (optional - users can set in UI)
# ===========================================
OPENAI_API_KEY=sk-...
FAL_KEY=...
# UGC Video
HEYGEN_API_KEY=...
DID_API_KEY=...
# ===========================================
# DEFAULT ENGINES
# ===========================================
DEFAULT_LLM_ENGINE=openai
DEFAULT_IMAGE_ENGINE=fal
DEFAULT_VIDEO_ENGINE=fal-video
DEFAULT_UGC_ENGINE=heygen
# ===========================================
# URLS (change for production)
# ===========================================
FRONTEND_URL=http://localhost:3000
CORS_ORIGINS=http://localhost:3000
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000
backend/.env
DATABASE_URL=sqlite:///./opensns.db
JWT_SECRET_KEY=your-secret-key
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=10080
API_KEY_ENCRYPTION_KEY=your-encryption-key
OPENAI_API_KEY=sk-...
FAL_KEY=...
DEFAULT_LLM_ENGINE=openai
DEFAULT_IMAGE_ENGINE=fal
DEFAULT_VIDEO_ENGINE=fal-video
DEFAULT_UGC_ENGINE=heygen
frontend/.env.local
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000

  1. Never commit .env files - They’re in .gitignore by default
  2. Use strong random keys - Generate with openssl rand -hex 32
  3. Rotate keys periodically - Especially JWT_SECRET_KEY
  4. Use PostgreSQL in production - SQLite is for development only
  5. Enable HTTPS - Required for secure cookie handling
  6. Restrict CORS origins - Only allow your actual frontend domain

Generate ad creatives from any product URL. Open source, self-hostable, free tier available.

Try OpenSNS Free →