Skip to content

Environment Variables

AgentZero reads several environment variables for API keys, backend selection, and runtime overrides.

All environment variables can be set in .env files instead of (or in addition to) the shell environment. AgentZero loads .env files from two locations:

  1. Config directory (~/.agentzero/.env) — global defaults
  2. Current working directory (./.env) — project-local overrides

Within each directory, files are loaded in this order (later overrides earlier):

  • .env — base values
  • .env.local — local overrides (typically gitignored)
  • .env.{AGENTZERO_ENV} — environment-specific (e.g. .env.production), selected via AGENTZERO_ENV, APP_ENV, or NODE_ENV

CWD files take priority over config-dir files. Process environment variables (export) take priority over all .env files.

VariableDescriptionDefault
OPENAI_API_KEYAPI key for OpenAI-compatible providers
AGENTZERO_ENVEnvironment mode (development or production). When production, startup validates TLS and auth are configureddevelopment
AGENTZERO_DATA_DIROverride data/config directory~/.agentzero
AGENTZERO_CONFIGOverride config file path$DATA_DIR/agentzero.toml
AGENTZERO_MEMORY_BACKENDMemory backend (sqlite or turso)sqlite
AGENTZERO_DATA_KEYEncryption key for storage (base64 or 64-char hex)auto-generated key file
AGENTZERO_GATEWAY_BEARER_TOKENStatic bearer token for gateway auth
RUST_LOGLogging level (also set via -v flags)
VariableDescription
OPENAI_API_KEYOpenAI, OpenRouter, or any OpenAI-compatible provider
ANTHROPIC_API_KEYAnthropic direct API access
BRAVE_API_KEYBrave Search API (for web_search tool)
PERPLEXITY_API_KEYPerplexity Search API
EXA_API_KEYExa Search API
JINA_API_KEYJina Reader/Search API
COMPOSIO_API_KEYComposio integration API
GROQ_API_KEYGroq API (used for audio transcription via [audio] config)
VariableDescription
AGENTZERO_MEMORY_BACKENDsqlite (default) or turso
TURSO_AUTH_TOKENAuth token for Turso/libsql remote backend
TURSO_DATABASE_URLTurso database URL

The -v flag maps to RUST_LOG levels:

Terminal window
agentzero -v status # RUST_LOG=error
agentzero -vv status # RUST_LOG=info
agentzero -vvv status # RUST_LOG=debug
agentzero -vvvv status # RUST_LOG=trace

Any command supports --json for machine-readable output:

Terminal window
agentzero --json status

Output format:

{
"ok": true,
"command": "status",
"result": { ... },
"error": null
}