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.
- 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
Base URL for Ollama serverRequired: Yes (to auto-configure Ollama)Docker examples:
- Windows/Mac:
http://host.docker.internal:11434 - Linux:
http://<host-ip>:11434
http://localhost:11434OpenAI
Your OpenAI API keyRequired: Yes (to auto-configure OpenAI)
Base URL for OpenAI APIRequired: Yes (to auto-configure OpenAI)Default:
https://api.openai.com/v1For OpenAI-compatible APIs, use your custom URLAnthropic
Your Anthropic API keyRequired: Yes (to auto-configure Anthropic)
Gemini
Your Google AI API key for GeminiRequired: Yes (to auto-configure Gemini)
Groq
Your Groq API keyRequired: Yes (to auto-configure Groq)
LM Studio
Base URL for LM Studio serverRequired: Yes (to auto-configure LM Studio)Default:
http://localhost:1234The /v1 suffix is added automaticallyLemonade
Base URL for Lemonade serverRequired: Yes (to auto-configure Lemonade)Example:
https://api.lemonade.ai/v1Your Lemonade API keyRequired: No (optional)
Search configuration
SearxNG
URL for your SearxNG instanceDefault:
http://localhost:8080 (bundled SearxNG)Override this when using an external SearxNG instanceThe bundled Perplexica image automatically sets
SEARXNG_API_URL=http://localhost:8080 for the included SearxNG instance.System configuration
Data directory
Directory where Perplexica stores configuration and dataDefault:
/home/perplexica/dataNote: This is automatically set in Docker imagesDocker detection
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:Docker Compose example
Using environment variables with Docker Compose:Using .env file
Create a.env file:
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
Example validation messages
Example validation messages
Environment variable precedence
Configuration priority (highest to lowest):- Existing configuration: Settings already saved in
config.json - Environment variables: Applied on startup for new providers
- 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
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
Troubleshooting
Provider not auto-configured
Check required variables are set
Check required variables are set
Each provider requires specific environment variables:
- Ollama:
OLLAMA_BASE_URL - OpenAI:
OPENAI_API_KEYANDOPENAI_BASE_URL - Anthropic:
ANTHROPIC_API_KEY - Gemini:
GEMINI_API_KEY - Groq:
GROQ_API_KEY - LM Studio:
LM_STUDIO_BASE_URL - Lemonade:
LEMONADE_BASE_URL
Verify environment variables are passed
Verify environment variables are passed
Check that Docker receives the variables:
Check logs for errors
Check logs for errors
View startup logs:
Values not updating
Environment variables are only processed on first initialization. If configuration already exists, environment variables won’t override it.
- Remove the existing provider in the settings UI
- Restart Perplexica
- Environment variables will create a new provider entry