Overview
LLM Gateway configuration is managed through environment variables. This page documents all available variables grouped by service.Database Configuration
PostgreSQL
PostgreSQL username for authentication.
PostgreSQL password. Use a strong password in production.
PostgreSQL database name.
PostgreSQL server port.
Complete PostgreSQL connection URL.Format:
postgres://user:password@host:port/databaseExample: postgres://postgres:pw@postgres:5432/llmgatewayRedis Configuration
Redis authentication password.
Redis server port.
Redis server hostname.
Service Ports
LLM Gateway service port.
Backend API service port.
Web dashboard port.
Playground interface port.
Admin dashboard port.
Documentation site port.
Dev plans/code landing page port.
URL Configuration
Public URL for the web dashboard.Example:
https://llmgateway.yourdomain.comPublic URL for the API service.Example:
https://api.llmgateway.yourdomain.comInternal URL for API service (used by frontend services).Example:
http://api:80 (in Docker/K8s)Public URL for the playground.Example:
https://playground.llmgateway.yourdomain.comPublic URL for documentation.Example:
https://docs.llmgateway.yourdomain.comPublic URL for admin dashboard.Example:
https://admin.llmgateway.yourdomain.comPublic URL for dev plans landing page.Example:
https://code.llmgateway.yourdomain.comComma-separated list of allowed CORS origins.Example:
https://llmgateway.yourdomain.com,https://playground.llmgateway.yourdomain.comAuthentication & Security
Secret key for session encryption. Generate with:
Domain for authentication cookies.Example:
yourdomain.comRelying Party ID for WebAuthn passkeys. Should match your domain.Example:
yourdomain.comRelying Party display name for WebAuthn passkeys.
OAuth Providers
GitHub OAuth application client ID. Optional - enables “Sign in with GitHub”.
GitHub OAuth application client secret.
Google OAuth application client ID. Optional - enables “Sign in with Google”.
Google OAuth application client secret.
Timeout Configuration
Health check timeout in milliseconds.
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.
Maximum time for end-to-end gateway request in milliseconds (5 minutes).
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 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
Stats calculator backfill duration in seconds (5 minutes).
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.Enable follow-up lifecycle emails.Set to
"true" to enable. Default just logs events without sending emails.Feature Flags
Platform fee percentage for credit usage (5%).Applied when users pay with credits using platform API keys.
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.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
OpenAI API key.Format:
sk-...Anthropic
Anthropic API key.Format:
sk-ant-...Google AI
Google AI Studio API key.
Google Vertex AI API key.
Google Cloud project ID for Vertex AI.
Google Vertex AI region.
Other Providers
Inference.net API key.
Together.ai API key.
Mistral AI API key.
Moonshot API key.
Novita AI API key.
xAI (Grok) API key.
Groq API key.
DeepSeek API key.
Perplexity API key.
Alibaba Cloud API key.
Nebius API key.
NanoGPT API key.
Z.ai API key.
AWS Bedrock API key.
Microsoft Azure OpenAI API key.
CanopyWave API key.
Payment Processing (Stripe)
Optional - only needed if you want to enable billing.Stripe secret key.Format:
sk_live_... (production) or sk_test_... (testing)Stripe webhook signing secret.Format:
whsec_...Stripe price ID for Pro monthly subscription.Format:
price_...Stripe price ID for Pro yearly subscription.Format:
price_...Dev Plans
Stripe price ID for Dev Plan Lite subscription.
Stripe price ID for Dev Plan Pro subscription.
Stripe price ID for Dev Plan Max subscription.
Credits multiplier for dev plan purchases (credits = price * multiplier).
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
Company name and address shown on invoices.Use
\n for line breaks.Example: Your Company Name\n123 Main St\nCity, State ZIP\nCountryEmail (Resend)
Required for transactional emails and contact management.Resend API key for sending emails.Format:
re_...Analytics (PostHog)
Optional - remove if you don’t want analytics.PostHog project API key.
PostHog instance URL.
Notifications
Discord webhook URL for notifications (signups, credit purchases).Leave empty to disable.
Example .env File
Security Best Practices
Generate Secure Secrets
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