AI Engagement Photos Docs

Environment Variables

Complete reference for all environment variables.

Required Variables

These variables are required for the application to function:

Database

DATABASE_URL="postgresql://user:password@host/db?sslmode=require"

Authentication

BETTER_AUTH_SECRET="at-least-32-characters-random-key"
BETTER_AUTH_URL="http://localhost:3000"

Application URL

NEXT_PUBLIC_APP_URL="http://localhost:3000"

Service Integrations

Kie.ai (Engagement Portraits)

Required for the production two-photo generation flow:

IMAGE_PROVIDER="kie"
KIE_API_KEY="your-kie-api-key"
KIE_API_BASE_URL="https://api.kie.ai"
KIE_IMAGE_MODEL="gpt-image-2-image-to-image"
KIE_IMAGE_ASPECT_RATIO="2:3"

Volcano Engine (Legacy Demos)

Only required when the bundled chat or video demos are enabled:

VOLCANO_ENGINE_API_KEY="your-volcano-engine-api-key"
VOLCANO_ENGINE_API_URL="https://ark.cn-beijing.volces.com/api/v3"

Creem (Payments)

Creem is the active provider. Waffo remains configured only as an explicit rollback option. Creem Test is allowed only against local or Preview data, never Production data:

PAYMENT_PROVIDER="creem"
BILLING_DATA_ENVIRONMENT="preview"
CREEM_ENVIRONMENT="test"
CREEM_TEST_API_KEY="your-creem-test-api-key"
CREEM_TEST_WEBHOOK_SECRET="whsec_..."
CREEM_TEST_PRODUCT_ID_STARTER_MONTHLY="prod_..."
CREEM_TEST_PRODUCT_ID_PRO_MONTHLY="prod_..."
CREEM_TEST_PRODUCT_ID_PACK_20="prod_..."
CREEM_TEST_PRODUCT_ID_PACK_50="prod_..."
CREEM_TEST_PRODUCT_ID_PACK_120="prod_..."

Set the Preview deployment's DATABASE_URL to a separate Neon branch or other non-Production PostgreSQL database. Configure BILLING_DATA_ENVIRONMENT="preview" explicitly when the deployment is not on Vercel. The webhook URL is:

https://your-preview-domain.com/api/payments/creem/webhook

Creem Live requires CREEM_ENVIRONMENT="live" and BILLING_DATA_ENVIRONMENT="production"; do not use those values for Test Mode.

Resend (Email)

Required for authentication emails and notifications:

RESEND_API_KEY="re_your_api_key"
RESEND_FROM_EMAIL="Your App <noreply@yourdomain.com>"

Google OAuth (Optional)

AUTH_GOOGLE_ID="your-google-client-id"
AUTH_GOOGLE_SECRET="your-google-client-secret"

Cron Jobs

CRON_SECRET="your-cron-secret"

Optional Analytics

NEXT_PUBLIC_POSTHOG_KEY="phc_..."
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID="G-..."
NEXT_PUBLIC_CLARITY_PROJECT_ID="..."

Engagement Storage (S3-Compatible)

R2 is required when IMAGE_PROVIDER="kie" so uploads and generated results remain under application control.

STORAGE_ENDPOINT="https://..."
STORAGE_BUCKET_NAME="your-bucket"
STORAGE_REGION="auto"
STORAGE_ACCESS_KEY_ID="..."
STORAGE_SECRET_ACCESS_KEY="..."
STORAGE_PUBLIC_URL="https://..."

On this page