Environment Variables

This document provides an explanation of the environment variables used in the big-AGI application.

All variables are optional; and UI options take precedence over backend environment variables, which take place over defaults. This file is kept in sync with ../src/server/env.mjs.

Setting Environment Variables

Environment variables can be set by creating a .env file in the root directory of the project.

The following is an example .env for copy-paste convenience:

# 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=
GEMINI_API_KEY=
GROQ_API_KEY=
LOCALAI_API_HOST=
LOCALAI_API_KEY=
MISTRAL_API_KEY=
OLLAMA_API_HOST=
OPENROUTER_API_KEY=
PERPLEXITY_API_KEY=
TOGETHERAI_API_KEY=

# Model Observability: Helicone
HELICONE_API_KEY=

# Text-To-Speech
ELEVENLABS_API_KEY=
ELEVENLABS_API_HOST=
ELEVENLABS_VOICE_ID=
# Text-To-Image
PRODIA_API_KEY=
# Google Custom Search
GOOGLE_CLOUD_API_KEY=
GOOGLE_CSE_ID=
# Browse
PUPPETEER_WSS_ENDPOINT=

# Backend Analytics
BACKEND_ANALYTICS=

# 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 only by the server-side code, at runtime. Define them before running the nextjs local server (in development or cloud deployment), or pass them to Docker (--env-file or -e) when starting the container.

Database

To enable Chat Link Sharing, you need to connect the backend to a database. We currently support Postgres and MongoDB.

For Database configuration see deploy-database.md.

LLMs

The following variables when set will enable the corresponding LLMs on the server-side, without requiring the user to enter an API key

VariableDescriptionRequired
OPENAI_API_KEYAPI key for OpenAIRecommended
OPENAI_API_HOSTChanges the backend host for the OpenAI vendor, to enable platforms such as Helicone and CloudFlare AI GatewayOptional
OPENAI_API_ORG_IDSets the "OpenAI-Organization" header field to support organization usersOptional
AZURE_OPENAI_API_ENDPOINTAzure OpenAI endpoint - host only, without the pathOptional, but if set AZURE_OPENAI_API_KEY must also be set
AZURE_OPENAI_API_KEYAzure OpenAI API key, see config-azure-openai.mdOptional, but if set AZURE_OPENAI_API_ENDPOINT must also be set
ANTHROPIC_API_KEYThe API key for AnthropicOptional
ANTHROPIC_API_HOSTChanges the backend host for the Anthropic vendor, to enable platforms such as config-aws-bedrock.mdOptional
GEMINI_API_KEYThe API key for Google AI's GeminiOptional
GROQ_API_KEYThe API key for Groq CloudOptional
LOCALAI_API_HOSTSets the URL of the LocalAI server, or defaults to http://127.0.0.1:8080Optional
LOCALAI_API_KEYThe (Optional) API key for LocalAIOptional
MISTRAL_API_KEYThe API key for MistralOptional
OLLAMA_API_HOSTChanges the backend host for the Ollama vendor. See config-local-ollama.md
OPENROUTER_API_KEYThe API key for OpenRouterOptional
PERPLEXITY_API_KEYThe API key for PerplexityOptional
TOGETHERAI_API_KEYThe API key for Together AIOptional

LLM Observability: Helicone

Helicone provides observability to your LLM calls. It is a paid service, with a generous free tier. It is currently supported for:

  • Anthropic: by setting the Helicone API key, Helicone is automatically activated
  • OpenAI: you also need to set OPENAI_API_HOST to oai.hconeai.com, to enable routing
VariableDescription
HELICONE_API_KEYThe API key for Helicone

Features

Enable the app to Talk, Draw, and Google things up.

VariableDescription
Text-To-SpeechElevenLabs is a high quality speech synthesis service
ELEVENLABS_API_KEYElevenLabs API Key - used for calls, etc.
ELEVENLABS_API_HOSTCustom host for ElevenLabs
ELEVENLABS_VOICE_IDDefault voice ID for ElevenLabs
Text-To-ImageProdia is a reliable image generation service
PRODIA_API_KEYProdia API Key - used with '/imagine ...'
Google Custom SearchGoogle Programmable Search Engine produces links to pages
GOOGLE_CLOUD_API_KEYGoogle Cloud API Key, used with the '/react' command - Link to GCP
GOOGLE_CSE_IDGoogle Custom/Programmable Search Engine ID - Link to PSE
Browse
PUPPETEER_WSS_ENDPOINTPuppeteer WebSocket endpoint - used for browsing (pade downloadeing), etc.
Backend
BACKEND_ANALYTICSSemicolon-separated list of analytics flags (see backend.analytics.ts). Flags: domain logs the responding domain.
HTTP_BASIC_AUTH_USERNAMESee the Authentication guide. Username for HTTP Basic Authentication.
HTTP_BASIC_AUTH_PASSWORDPassword for HTTP Basic Authentication.

Frontend Variables

The value of these variables are passed to the frontend (Web UI) - make sure they do not contain secrets.

VariableDescription
NEXT_PUBLIC_GA4_MEASUREMENT_IDThe measurement ID for Google Analytics 4. (see deploy-analytics)
NEXT_PUBLIC_PLANTUML_SERVER_URLThe URL of the PlantUML server, used for rendering UML diagrams. (code in RederCode.tsx)

Important: these variables must be set at build time, which is required by Next.js to pass them to the frontend. This is in contrast to the backend variables, which can be set when starting the local server/container.


For a higher level overview of backend code and environment customization, see the big-AGI Customization guide.