Skip to main content
DeepWiki-Open uses environment variables to configure AI providers, server settings, authentication, and advanced features. This guide covers all available environment variables and their usage.

Required Environment Variables

At minimum, you need API keys for at least one AI provider:

AI Provider Configuration

Google Gemini

Google AI Studio API key for Gemini models. How to get:
  1. Visit Google AI Studio
  2. Click “Create API Key”
  3. Copy the generated key
Supported models:
  • gemini-2.0-flash (default, recommended)
  • gemini-1.5-flash
  • gemini-1.0-pro
Google Gemini offers generous free tier limits and excellent performance for documentation generation.

OpenAI

OpenAI API key for GPT models. Custom OpenAI API endpoint (for OpenAI-compatible services). How to get:
  1. Visit OpenAI Platform
  2. Create new secret key
  3. Copy the key (starts with sk-)
Supported models:
  • gpt-4o (default)
  • gpt-4.1
  • o1
  • o3
  • o4-mini
OpenAI requires a paid account. Free tier users cannot access the API.

OpenRouter

OpenRouter API key for access to multiple model providers. How to get:
  1. Sign up at OpenRouter
  2. Go to Keys section
  3. Create new API key
Available models:
  • openai/gpt-4o
  • anthropic/claude-3.5-sonnet
  • deepseek/deepseek-r1
  • google/gemini-pro
  • And 100+ more models
OpenRouter provides access to multiple AI providers through a single API, perfect for comparing models.

Azure OpenAI

Azure OpenAI service API key. Your Azure OpenAI resource endpoint URL. API version (e.g., 2024-02-15-preview). How to get:
  1. Create Azure OpenAI resource in Azure Portal
  2. Deploy a model (GPT-4, GPT-3.5-turbo, etc.)
  3. Get endpoint and API key from resource overview
  4. Note the API version from the deployment
Example configuration:

AWS Bedrock

AWS access key for Bedrock access. AWS secret access key. AWS region where Bedrock models are available. Supported models:
  • anthropic.claude-3-sonnet-20240229-v1:0
  • anthropic.claude-3-haiku-20240307-v1:0
  • anthropic.claude-3-opus-20240229-v1:0
  • amazon.titan-text-express-v1

Ollama (Local Models)

Ollama server URL for local AI models. Setup Ollama:
Supported models:
  • qwen3:1.7b (lightweight)
  • llama3:8b (balanced)
  • qwen3:8b (high context)

DashScope (Alibaba)

Alibaba DashScope API key for Qwen models. How to get:
  1. Sign up at DashScope
  2. Create API key in console
  3. Add key to environment
Supported models:
  • qwen-plus
  • qwen-turbo
  • deepseek-r1

Server Configuration

Port for the FastAPI backend server. Base URL for API server (used by frontend). Environment mode (development, production, test). Example server configuration:

Security & Authentication

Authorization Mode

Enable authorization requirement for wiki generation. Secret code required when authorization mode is enabled. Usage:
When enabled, users must enter the auth code to generate wikis.
Authorization mode provides basic frontend protection but doesn’t secure direct API access.

Logging & Debugging

Logging verbosity level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL Path for log file output. Example logging configuration:
In production, use INFO or WARNING level to reduce log volume.

Advanced Configuration

Directory containing configuration JSON files. Redis connection URL for caching (optional). Example:

Environment File Templates

Development

Production

Docker

Validation & Testing

1

Validate Environment

2

Test API Connections

3

Verify Frontend Connection

Security Best Practices

  • Never commit .env files to version control
  • Use different API keys for development and production
  • Regularly rotate API keys
  • Monitor API usage for unexpected activity
  • Use environment-specific keys when possible
  • Use HTTPS in production
  • Configure proper CORS settings
  • Use private networks for internal components
  • Enable authorization mode for public deployments

Troubleshooting

Symptoms: API key errors, default values usedSolutions:
  1. Verify .env file is in project root
  2. Check file permissions (readable by application)
  3. Ensure no syntax errors in .env file
  4. Restart application after changes
Symptoms: “Invalid API key” errorsSolutions:
  1. Test API keys with provider’s documentation
  2. Check for extra spaces or characters
  3. Verify key has correct permissions/scopes
  4. Confirm key hasn’t expired or been revoked
Symptoms: “Port already in use” errorsSolutions:
  1. Change PORT environment variable
  2. Kill existing processes on the port
  3. Use Docker with port mapping
  4. Configure reverse proxy

Next Steps

Model Provider Setup

Configure specific AI model providers and their settings

Production Deployment

Deploy DeepWiki with production-ready configuration

Configuration Files

Learn about JSON configuration files for advanced customization

Security Guide

Implement security best practices for production deployments