Tutorial

OpenClaw Environment Variables Reference

February 14, 20264 min readUpdated September 11, 2026By OpenClawBlog Team
January 31, 2026 4 min read

OpenClaw can be configured through environment variables. This is particularly useful for sensitive data like API keys and for containerized deployments.

Setting Environment Variables

# Temporarily (current session) export OPENCLAW_LOG_LEVEL=debug # Permanently (add to ~/.bashrc or ~/.zshrc) echo 'export OPENCLAW_LOG_LEVEL=debug' >> ~/.bashrc # For a single command OPENCLAW_LOG_LEVEL=debug openclaw chat

Core Variables

Variable Description Default
OPENCLAW_CONFIG_DIR Custom config directory path ~/.config/openclaw
OPENCLAW_DATA_DIR Custom data directory path ~/.local/share/openclaw
OPENCLAW_LOG_LEVEL Logging verbosity info
OPENCLAW_DAEMON_PORT Daemon HTTP port 3000
OPENCLAW_NO_COLOR Disable colored output false

API Keys

Variable Description Provider
ANTHROPIC_API_KEY Claude API key Anthropic
OPENAI_API_KEY OpenAI API key OpenAI
OPENCLAW_DEFAULT_MODEL Default model to use Any
Security: Environment variables take precedence over config file values. Use them for sensitive data to avoid accidentally committing API keys to version control.

Integration Variables

Variable Description
DISCORD_BOT_TOKEN Discord bot token
TELEGRAM_BOT_TOKEN Telegram bot token
SLACK_BOT_TOKEN Slack bot token
WHATSAPP_PHONE_ID WhatsApp phone number ID
WHATSAPP_ACCESS_TOKEN WhatsApp access token

Log Levels

Level Description
debug Verbose logging for troubleshooting
info General informational messages
warn Warnings and errors only
error Errors only

Docker / Compose Example

# docker-compose.yml services: openclaw: image: openclaw/openclaw:latest environment: - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} - OPENCLAW_LOG_LEVEL=info - DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN} volumes: - openclaw-data:/data volumes: openclaw-data:

.env File

For convenience, use a .env file in your project directory:

# .env ANTHROPIC_API_KEY=sk-ant-... OPENCLAW_LOG_LEVEL=info DISCORD_BOT_TOKEN=MTE...
Remember: Add .env to your .gitignore file to prevent committing sensitive data.

Related Articles


References

  1. OpenClaw Official Documentation - https://docs.openclaw.ai/ - Accessed February 2026
  2. OpenClaw GitHub Repository - https://github.com/openclaw/openclaw - Accessed February 2026
  3. OpenClaw Configuration Guide - Environment & Configuration - Accessed February 2026
  4. Anthropic API Keys - Anthropic Console - Accessed February 2026

Configure with confidence

Use environment variables for secure, flexible OpenClaw configuration.

Learn More

Reference Trail

Sources and further reading

  1. https://docs.openclaw.ai/docs.openclaw.ai
  2. https://github.com/openclaw/openclawgithub.com
  3. Environment & Configurationdocs.openclaw.ai
  4. Anthropic Consoleconsole.anthropic.com
Back to ArchiveMore: TutorialsNext: OpenClaw Model Selection: Which LLM to Use