Skip to main content
Perplexica can be configured using environment variables, which is especially useful for Docker deployments and automation.

How environment variables work

Environment variables are processed on container startup. If a required environment variable is set (with valid configuration), the corresponding provider is automatically configured.
Environment variables:
  • Are applied when Perplexica starts
  • Create provider configurations automatically
  • Are merged with existing configuration
  • Take precedence on first initialization

Provider configuration

Configure LLM providers using environment variables.

Ollama

string
Base URL for Ollama serverRequired: Yes (to auto-configure Ollama)Docker examples:
  • Windows/Mac: http://host.docker.internal:11434
  • Linux: http://<host-ip>:11434
Non-Docker: http://localhost:11434

OpenAI

string
Your OpenAI API keyRequired: Yes (to auto-configure OpenAI)
string
default:"https://api.openai.com/v1"
Base URL for OpenAI APIRequired: Yes (to auto-configure OpenAI)Default: https://api.openai.com/v1For OpenAI-compatible APIs, use your custom URL

Anthropic

string
Your Anthropic API keyRequired: Yes (to auto-configure Anthropic)

Gemini

string
Your Google AI API key for GeminiRequired: Yes (to auto-configure Gemini)

Groq

string
Your Groq API keyRequired: Yes (to auto-configure Groq)

LM Studio

string
Base URL for LM Studio serverRequired: Yes (to auto-configure LM Studio)Default: http://localhost:1234The /v1 suffix is added automatically

Lemonade

string
Base URL for Lemonade serverRequired: Yes (to auto-configure Lemonade)Example: https://api.lemonade.ai/v1
string
Your Lemonade API keyRequired: No (optional)

Search configuration

SearxNG

string
default:"http://localhost:8080"
URL for your SearxNG instanceDefault: http://localhost:8080 (bundled SearxNG)Override this when using an external SearxNG instance
The bundled Perplexica image automatically sets SEARXNG_API_URL=http://localhost:8080 for the included SearxNG instance.

System configuration

Data directory

string
default:"/home/perplexica/data"
Directory where Perplexica stores configuration and dataDefault: /home/perplexica/dataNote: This is automatically set in Docker images
Changing DATA_DIR is not recommended unless you have a specific use case. Ensure you mount a volume to the new location.

Docker detection

boolean
Indicates whether Perplexica is running in DockerSet by: Docker images automaticallyEffect: Changes default URLs (e.g., Ollama URL suggestions)

Multiple providers

You can configure multiple providers simultaneously:
Configuring multiple providers gives you flexibility to choose different models for different tasks.

Docker Compose example

Using environment variables with Docker Compose:

Using .env file

Create a .env file:
Then use with Docker Compose:
Never commit .env files containing API keys to version control. Add .env to your .gitignore.

Non-Docker usage

For non-Docker installations, set environment variables before starting:

Linux/Mac

Windows (PowerShell)

Windows (Command Prompt)

Validation

Perplexica validates environment variables on startup:
  • Missing required fields: Provider is not auto-configured
  • Invalid values: Error logged, provider skipped
  • Connection test: Providers are tested when configured
Check logs for validation messages:

Environment variable precedence

Configuration priority (highest to lowest):
  1. Existing configuration: Settings already saved in config.json
  2. Environment variables: Applied on startup for new providers
  3. Defaults: Built-in defaults (e.g., OpenAI base URL)
If a provider with the same configuration already exists (matched by hash), environment variables won’t create a duplicate.

Security considerations

Never expose API keys in:
  • Public repositories
  • Container images
  • Logs or error messages
  • Unencrypted storage
Best practices:
  • Use Docker secrets or orchestration tools (Kubernetes secrets, etc.)
  • Rotate API keys regularly
  • Use read-only API keys when possible
  • Restrict network access to Perplexica
  • Use HTTPS for external API endpoints
For production deployments, consider using secret management tools like:
  • Docker Swarm secrets
  • Kubernetes secrets
  • HashiCorp Vault
  • AWS Secrets Manager
  • Azure Key Vault

Troubleshooting

Provider not auto-configured

Each provider requires specific environment variables:
  • Ollama: OLLAMA_BASE_URL
  • OpenAI: OPENAI_API_KEY AND OPENAI_BASE_URL
  • Anthropic: ANTHROPIC_API_KEY
  • Gemini: GEMINI_API_KEY
  • Groq: GROQ_API_KEY
  • LM Studio: LM_STUDIO_BASE_URL
  • Lemonade: LEMONADE_BASE_URL
Missing any required variable prevents auto-configuration.
Check that Docker receives the variables:
View startup logs:

Values not updating

Environment variables are only processed on first initialization. If configuration already exists, environment variables won’t override it.
To force reconfiguration:
  1. Remove the existing provider in the settings UI
  2. Restart Perplexica
  3. Environment variables will create a new provider entry
Or delete the configuration file (⚠️ removes all settings):

Next steps