Skip to main content

Overview

LLM Gateway configuration is managed through environment variables. This page documents all available variables grouped by service.

Database Configuration

PostgreSQL

POSTGRES_USER
string
default:"postgres"
PostgreSQL username for authentication.
POSTGRES_PASSWORD
string
required
PostgreSQL password. Use a strong password in production.
POSTGRES_DB
string
default:"llmgateway"
PostgreSQL database name.
POSTGRES_PORT
number
default:"5432"
PostgreSQL server port.
DATABASE_URL
string
required
Complete PostgreSQL connection URL.Format: postgres://user:password@host:port/databaseExample: postgres://postgres:pw@postgres:5432/llmgateway

Redis Configuration

REDIS_PASSWORD
string
required
Redis authentication password.
REDIS_PORT
number
default:"6379"
Redis server port.
REDIS_HOST
string
default:"redis"
Redis server hostname.

Service Ports

GATEWAY_PORT
number
default:"4001"
LLM Gateway service port.
API_PORT
number
default:"4002"
Backend API service port.
UI_PORT
number
default:"3002"
Web dashboard port.
PLAYGROUND_PORT
number
default:"3003"
Playground interface port.
ADMIN_PORT
number
default:"3006"
Admin dashboard port.
DOCS_PORT
number
default:"3005"
Documentation site port.
CODE_PORT
number
default:"3004"
Dev plans/code landing page port.

URL Configuration

UI_URL
string
default:"http://localhost:3002"
Public URL for the web dashboard.Example: https://llmgateway.yourdomain.com
API_URL
string
default:"http://localhost:4002"
Public URL for the API service.Example: https://api.llmgateway.yourdomain.com
API_BACKEND_URL
string
default:"http://localhost:4002"
Internal URL for API service (used by frontend services).Example: http://api:80 (in Docker/K8s)
PLAYGROUND_URL
string
default:"http://localhost:3003"
Public URL for the playground.Example: https://playground.llmgateway.yourdomain.com
DOCS_URL
string
default:"http://localhost:3005"
Public URL for documentation.Example: https://docs.llmgateway.yourdomain.com
ADMIN_URL
string
default:"http://localhost:3006"
Public URL for admin dashboard.Example: https://admin.llmgateway.yourdomain.com
CODE_URL
string
default:"http://localhost:3004"
Public URL for dev plans landing page.Example: https://code.llmgateway.yourdomain.com
ORIGIN_URLS
string
default:"http://localhost:3002"
Comma-separated list of allowed CORS origins.Example: https://llmgateway.yourdomain.com,https://playground.llmgateway.yourdomain.com

Authentication & Security

AUTH_SECRET
string
required
Secret key for session encryption. Generate with:
openssl rand -base64 32
Domain for authentication cookies.Example: yourdomain.com
PASSKEY_RP_ID
string
default:"localhost"
Relying Party ID for WebAuthn passkeys. Should match your domain.Example: yourdomain.com
PASSKEY_RP_NAME
string
default:"LLMGateway"
Relying Party display name for WebAuthn passkeys.

OAuth Providers

GITHUB_CLIENT_ID
string
GitHub OAuth application client ID. Optional - enables “Sign in with GitHub”.
GITHUB_CLIENT_SECRET
string
GitHub OAuth application client secret.
GOOGLE_CLIENT_ID
string
Google OAuth application client ID. Optional - enables “Sign in with Google”.
GOOGLE_CLIENT_SECRET
string
Google OAuth application client secret.

Timeout Configuration

TIMEOUT_MS
number
default:"5000"
Health check timeout in milliseconds.
KEEP_ALIVE_TIMEOUT_S
number
default:"620"
HTTP server keep-alive timeout in seconds. Should be higher than your load balancer’s keepalive timeout to prevent 502 errors.Default is 620s for gateway and 60s for API. GCP Load Balancer uses 600s, so gateway default is set higher.
GATEWAY_TIMEOUT_MS
number
default:"300000"
Maximum time for end-to-end gateway request in milliseconds (5 minutes).
AI_STREAMING_TIMEOUT_MS
number
default:"240000"
AI provider request timeout for streaming requests in milliseconds (4 minutes).Should be shorter than GATEWAY_TIMEOUT_MS to allow for error handling. Defaults to 80% of GATEWAY_TIMEOUT_MS.
AI_TIMEOUT_MS
number
default:"180000"
AI provider request timeout for non-streaming requests in milliseconds (3 minutes).Non-streaming requests use a shorter timeout since they don’t benefit from incremental responses.

Worker Configuration

BACKFILL_DURATION_SECONDS
number
default:"300"
Stats calculator backfill duration in seconds (5 minutes).
ENABLE_DATA_RETENTION_CLEANUP
boolean
default:"false"
Enable automatic deletion of verbose log data after retention period.Set to "true" to enable. When enabled, verbose fields are nullified after 30 days for all users.
EMAIL_FOLLOW_UPS
boolean
default:"false"
Enable follow-up lifecycle emails.Set to "true" to enable. Default just logs events without sending emails.

Feature Flags

PLATFORM_FEE_PERCENTAGE
number
default:"0.05"
Platform fee percentage for credit usage (5%).Applied when users pay with credits using platform API keys.
BILL_CANCELLED_REQUESTS
boolean
default:"true"
Bill cancelled requests based on estimated token usage.When enabled, cancelled requests are billed for prompt tokens and any partial completion tokens that were streamed before cancellation, plus request costs.Set to "false" to disable.
IMAGE_SIZE_LIMIT_MB
number
default:"100"
Maximum image upload size in megabytes.

LLM Provider API Keys

Add API keys for the providers you want to use. You don’t need all of them.

OpenAI

LLM_OPENAI_API_KEY
string
OpenAI API key.Format: sk-...

Anthropic

LLM_ANTHROPIC_API_KEY
string
Anthropic API key.Format: sk-ant-...

Google AI

LLM_GOOGLE_AI_STUDIO_API_KEY
string
Google AI Studio API key.
LLM_GOOGLE_VERTEX_API_KEY
string
Google Vertex AI API key.
LLM_GOOGLE_CLOUD_PROJECT
string
Google Cloud project ID for Vertex AI.
LLM_GOOGLE_VERTEX_REGION
string
default:"global"
Google Vertex AI region.

Other Providers

LLM_INFERENCE_NET_API_KEY
string
Inference.net API key.
LLM_TOGETHER_AI_API_KEY
string
Together.ai API key.
LLM_MISTRAL_API_KEY
string
Mistral AI API key.
LLM_MOONSHOT_API_KEY
string
Moonshot API key.
LLM_NOVITA_AI_API_KEY
string
Novita AI API key.
LLM_X_AI_API_KEY
string
xAI (Grok) API key.
LLM_GROQ_API_KEY
string
Groq API key.
LLM_DEEPSEEK_API_KEY
string
DeepSeek API key.
LLM_PERPLEXITY_API_KEY
string
Perplexity API key.
LLM_ALIBABA_API_KEY
string
Alibaba Cloud API key.
LLM_NEBIUS_API_KEY
string
Nebius API key.
LLM_NANO_GPT_API_KEY
string
NanoGPT API key.
LLM_Z_AI_API_KEY
string
Z.ai API key.
LLM_AWS_BEDROCK_API_KEY
string
AWS Bedrock API key.
LLM_AZURE_API_KEY
string
Microsoft Azure OpenAI API key.
LLM_CANOPY_WAVE_API_KEY
string
CanopyWave API key.

Payment Processing (Stripe)

Optional - only needed if you want to enable billing.
STRIPE_SECRET_KEY
string
Stripe secret key.Format: sk_live_... (production) or sk_test_... (testing)
STRIPE_WEBHOOK_SECRET
string
Stripe webhook signing secret.Format: whsec_...
STRIPE_PRO_MONTHLY_PRICE_ID
string
Stripe price ID for Pro monthly subscription.Format: price_...
STRIPE_PRO_YEARLY_PRICE_ID
string
Stripe price ID for Pro yearly subscription.Format: price_...

Dev Plans

STRIPE_DEV_PLAN_LITE_PRICE_ID
string
Stripe price ID for Dev Plan Lite subscription.
STRIPE_DEV_PLAN_PRO_PRICE_ID
string
Stripe price ID for Dev Plan Pro subscription.
STRIPE_DEV_PLAN_MAX_PRICE_ID
string
Stripe price ID for Dev Plan Max subscription.
DEV_PLAN_CREDITS_MULTIPLIER
number
default:"3"
Credits multiplier for dev plan purchases (credits = price * multiplier).
FIRST_TIME_CREDIT_BONUS_MULTIPLIER
number
First-time credit purchase bonus multiplier.Example: 1.5 = 50% bonus on first credit purchase (max $50 bonus)Leave unset or empty to disable bonus.

Invoicing

INVOICE_FROM
string
default:"Fake Company\\nUnited States"
Company name and address shown on invoices.Use \n for line breaks.Example: Your Company Name\n123 Main St\nCity, State ZIP\nCountry

Email (Resend)

Required for transactional emails and contact management.
RESEND_API_KEY
string
Resend API key for sending emails.Format: re_...

Analytics (PostHog)

Optional - remove if you don’t want analytics.
POSTHOG_KEY
string
PostHog project API key.
POSTHOG_HOST
string
default:"https://app.posthog.com"
PostHog instance URL.

Notifications

DISCORD_NOTIFICATION_URL
string
Discord webhook URL for notifications (signups, credit purchases).Leave empty to disable.

Example .env File

# Copy this to .env and update the values

# Database
POSTGRES_USER=postgres
POSTGRES_PASSWORD=change_this_secure_password
POSTGRES_DB=llmgateway
POSTGRES_PORT=5432
DATABASE_URL=postgres://postgres:change_this_secure_password@postgres:5432/llmgateway

# Redis
REDIS_PASSWORD=change_this_redis_password
REDIS_PORT=6379

# Service Ports
GATEWAY_PORT=4001
API_PORT=4002
UI_PORT=3002
PLAYGROUND_PORT=3003
ADMIN_PORT=3006

# URLs (update for your domain)
UI_URL=https://llmgateway.yourdomain.com
API_URL=https://api.llmgateway.yourdomain.com
ORIGIN_URLS=https://llmgateway.yourdomain.com

# Authentication
AUTH_SECRET=generate-with-openssl-rand-base64-32
COOKIE_DOMAIN=yourdomain.com
PASSKEY_RP_ID=yourdomain.com
PASSKEY_RP_NAME=LLMGateway

# GitHub OAuth (optional)
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret

# Google OAuth (optional)
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

# LLM Providers (add the ones you need)
LLM_OPENAI_API_KEY=sk-your_openai_key_here
LLM_ANTHROPIC_API_KEY=sk-ant-your_anthropic_key_here

# Stripe (optional)
STRIPE_SECRET_KEY=sk_live_your-key
STRIPE_WEBHOOK_SECRET=whsec_your-secret
STRIPE_PRO_MONTHLY_PRICE_ID=price_your-id
STRIPE_PRO_YEARLY_PRICE_ID=price_your-id

# Email (optional)
RESEND_API_KEY=re_your-key

# Analytics (optional)
POSTHOG_KEY=your-key
POSTHOG_HOST=https://app.posthog.com

Security Best Practices

Never commit .env files to version control. Add .env to your .gitignore.

Generate Secure Secrets

# Generate AUTH_SECRET
openssl rand -base64 32

# Generate passwords
openssl rand -base64 24

Use Secrets Management

For production:
  • Docker - Use Docker secrets
  • Kubernetes - Use Kubernetes secrets or external secrets operator
  • Cloud - Use AWS Secrets Manager, Google Secret Manager, Azure Key Vault
  • HashiCorp Vault - For on-premise deployments

Rotate Credentials

Regularly rotate:
  • Database passwords
  • Redis passwords
  • AUTH_SECRET
  • API keys
  • OAuth secrets

Build docs developers (and LLMs) love