This document lists all environment variables used by OpenClaw instances in the Hatchery.
At least one of the following LLM API keys must be set:
ANTHROPIC_API_KEY— Anthropic Claude API keyOPENAI_API_KEY— OpenAI API keyXAI_API_KEY— xAI API key (Grok)GOOGLE_API_KEY— Google AI API key (Gemini)
The following variables are automatically set by entrypoint.sh based on which API key is available. You can override them explicitly if needed.
LLM_PROVIDER— LLM provider name (e.g.anthropic,openai,google,xai)LLM_MODEL— Model name to use (e.g.claude-3-5-sonnet-20241022,gpt-4o)LLM_API_KEY— The API key passed to the provider (resolved from the provider-specific key)
Auto-detection rules (when LLM_PROVIDER is not set explicitly):
| Keys set | Provider | Model |
|---|---|---|
Only ANTHROPIC_API_KEY |
anthropic |
claude-3-5-sonnet-20241022 |
Only OPENAI_API_KEY |
openai |
gpt-4o |
Only GOOGLE_API_KEY |
google |
gemini-2.0-flash |
Only XAI_API_KEY |
xai |
grok-3-mini |
| Multiple keys | anthropic |
claude-3-5-sonnet-20241022 |
You can override detection by setting LLM_PROVIDER, LLM_MODEL, and LLM_API_KEY explicitly in your .env.
OC_VERSION— Version of theopenclawnpm package to install in the Docker image. Defaults tolatest. Set to a specific version (e.g.2026.2.17) for reproducible builds.
Only required if you want to connect OpenClaw to Discord:
DISCORD_BOT_TOKEN— Discord bot tokenDISCORD_CLIENT_ID— Discord application client ID
To enable Discord:
- Set both
DISCORD_BOT_TOKENandDISCORD_CLIENT_IDin your.env - Ensure the Discord section in
openclaw.template.jsonhas"enabled": true
- Environment variables are set in your instance's
.envfile - Template processing happens at container startup via
entrypoint.sh - envsubst replaces
$VARIABLE_NAMEplaceholders inopenclaw.template.json - Final config is generated at
/home/openclaw/.openclaw/openclaw.json - OpenClaw starts and reads the generated config
- Never commit
.envfiles oropenclaw.jsonto version control openclaw.jsonis runtime-generated and listed in.gitignore- Use
.env.exampleas a template for required variables - Secrets are only stored in
.envor your environment, never in committed files
To see the generated config (with redacted secrets), set DEBUG=1 in your .env:
DEBUG=1Then check container logs:
docker compose logs# Required: At least one LLM provider
ANTHROPIC_API_KEY=your-anthropic-api-key-here
# Optional: Additional LLM providers
# OPENAI_API_KEY=your-openai-api-key-here
# XAI_API_KEY=your-xai-api-key-here
# GOOGLE_API_KEY=your-google-api-key
# Optional: Discord integration
# DISCORD_BOT_TOKEN=your-discord-bot-token
# DISCORD_CLIENT_ID=your-discord-client-id
# Optional: Debug mode
# DEBUG=1You can modify openclaw.template.json to add more configuration options. Any $VARIABLE_NAME will be replaced by envsubst at startup.
- Add the variable to your instance's
.envfile - Add
$VARIABLE_NAMEplaceholder toopenclaw.template.json - (Optional) Export a default in
entrypoint.shto prevent empty strings - Document the variable in this file
To add a custom workspace path:
In .env:
CUSTOM_WORKSPACE_PATH=/custom/pathIn openclaw.template.json:
{
"workspace": {
"path": "$CUSTOM_WORKSPACE_PATH"
}
}In entrypoint.sh (optional defaults):
export CUSTOM_WORKSPACE_PATH="${CUSTOM_WORKSPACE_PATH:-/home/openclaw/.openclaw/workspace}"