.ENV
All variables are optional, and their priority is as follows: UI options override backend environment variables, which in turn override defaults. This document stays in sync with ../src/server/env.mjs.
Setting Environment Variables
You can define environment variables by creating a .env file in the project’s root directory.
Here’s an example .env file for reference and copy-paste:
# Database (Postgres)
POSTGRES_PRISMA_URL=
POSTGRES_URL_NON_POOLING=
# Database (MongoDB)
MDB_URI=
# LLMs
OPENAI_API_KEY=
OPENAI_API_HOST=
OPENAI_API_ORG_ID=
AZURE_OPENAI_API_ENDPOINT=
AZURE_OPENAI_API_KEY=
ANTHROPIC_API_KEY=
ANTHROPIC_API_HOST=
DEEPSEEK_API_KEY=
GEMINI_API_KEY=
GROQ_API_KEY=
LOCALAI_API_HOST=
LOCALAI_API_KEY=
MISTRAL_API_KEY=
OLLAMA_API_HOST=
OPENPIPE_API_KEY=
OPENROUTER_API_KEY=
PERPLEXITY_API_KEY=
TOGETHERAI_API_KEY=
XAI_API_KEY=
# Model Observability: Helicone
HELICONE_API_KEY=
# Browse
PUPPETEER_WSS_ENDPOINT=
# Search
GOOGLE_CLOUD_API_KEY=
GOOGLE_CSE_ID=
# Text-To-Speech: ElevenLabs
ELEVENLABS_API_KEY=
ELEVENLABS_API_HOST=
ELEVENLABS_VOICE_ID=
# Text-To-Image: Prodia
PRODIA_API_KEY=
# Backend HTTP Basic Authentication (see `deploy-authentication.md` for turning on authentication)
HTTP_BASIC_AUTH_USERNAME=
HTTP_BASIC_AUTH_PASSWORD=
# Frontend variables
NEXT_PUBLIC_GA4_MEASUREMENT_ID=
NEXT_PUBLIC_PLANTUML_SERVER_URL=Backend Variables
These variables are used exclusively by server-side processes at runtime. They must be defined before running the Next.js local server (in development or deployment), or they can be passed to Docker using the --env-file flag or the -e option when starting the container.
Database Configuration
To enable Chat Link Sharing, connect the backend to a database. The application supports both Postgres and MongoDB. For details, refer to the Database Deployment Guide.
LLM Variables
These variables configure various LLM integrations on the server-side. When set, they enable the respective models without requiring users to input API keys manually.
Variable
Description
Required
OPENAI_API_KEY
API key for OpenAI
Recommended
OPENAI_API_HOST
Changes the backend host for OpenAI (e.g., to use platforms like Helicone or CloudFlare AI Gateway)
Optional
OPENAI_API_ORG_ID
Specifies the "OpenAI-Organization" header to support organizational users
Optional
AZURE_OPENAI_API_ENDPOINT
Azure OpenAI endpoint (host only, without the path)
Optional, but requires AZURE_OPENAI_API_KEY
AZURE_OPENAI_API_KEY
Azure OpenAI API key (Azure OpenAI Config Guide)
Optional, but requires AZURE_OPENAI_API_ENDPOINT
ANTHROPIC_API_KEY
API key for Anthropic
Optional
ANTHROPIC_API_HOST
Custom Anthropic backend host (e.g., AWS Bedrock)
Optional
DEEPSEEK_API_KEY
API key for Deepseek AI
Optional
GEMINI_API_KEY
API key for Google AI’s Gemini
Optional
GROQ_API_KEY
API key for Groq Cloud
Optional
LOCALAI_API_HOST
URL for the LocalAI server (defaults to http://127.0.0.1:8080)
Optional
LOCALAI_API_KEY
Optional API key for LocalAI
Optional
MISTRAL_API_KEY
API key for Mistral
Optional
OLLAMA_API_HOST
Custom Ollama backend host (Ollama Configuration Guide)
Optional
OPENPIPE_API_KEY
API key for OpenPipe
Optional
OPENROUTER_API_KEY
API key for OpenRouter
Optional
PERPLEXITY_API_KEY
API key for Perplexity
Optional
TOGETHERAI_API_KEY
API key for Together AI
Optional
XAI_API_KEY
API key for xAI
Optional
Observability with Helicone
Helicone is a paid service that provides observability for LLM calls. It includes a free tier and supports the following:
Anthropic: Helicone activates automatically when the API key is set.
OpenAI: Set
OPENAI_API_HOSTtooai.hconeai.comfor Helicone routing.
Variable
Description
HELICONE_API_KEY
API key for Helicone
Feature Configuration
These variables enable additional features such as text-to-speech, text-to-image generation, and web browsing.
Feature
Variable
Description
Text-to-Speech
ELEVENLABS_API_KEY
API key for ElevenLabs
ELEVENLABS_API_HOST
Custom ElevenLabs host
ELEVENLABS_VOICE_ID
Default ElevenLabs voice ID
Text-to-Image
PRODIA_API_KEY
API key for Prodia (used with /imagine)
Browse
PUPPETEER_WSS_ENDPOINT
WebSocket endpoint for Puppeteer, used for web browsing
Backend
HTTP_BASIC_AUTH_USERNAME
Username for HTTP Basic Authentication (Guide)
HTTP_BASIC_AUTH_PASSWORD
Password for HTTP Basic Authentication
Frontend Variables
The following variables are passed to the Web UI and must not contain secrets. They are configured at build time and made available via Next.js.
Variable
Description
NEXT_PUBLIC_GA4_MEASUREMENT_ID
Google Analytics 4 Measurement ID (Analytics Deployment Guide)
NEXT_PUBLIC_PLANTUML_SERVER_URL
URL of the PlantUML server for rendering UML diagrams (used in RenderCode.tsx)
Important: Frontend variables must be defined at build time because Next.js embeds them into the frontend. This differs from backend variables, which can be set at runtime when starting the server or container.