Skip to content

Environment Variables

When running without a config file, the CLI reads these environment variables to configure the agent.

VariableDefaultDescription
ANTHROPIC_API_KEYAnthropic API key (required for anthropic provider)
OPENROUTER_API_KEYOpenRouter API key (required for openrouter provider)
HEARTBIT_PROVIDERauto-detectForce provider (anthropic / openrouter)
HEARTBIT_MODELclaude-sonnet-4-20250514Override model name
HEARTBIT_MAX_TURNS50 (run) / 200 (chat)Max agent turns
HEARTBIT_PROMPT_CACHINGfalseEnable Anthropic prompt caching (1 or true)
HEARTBIT_SUMMARIZE_THRESHOLD80000Token count to trigger context summarization
HEARTBIT_MAX_TOOL_OUTPUT_BYTES32768Max bytes per tool output before truncation
HEARTBIT_TOOL_TIMEOUT120Tool execution timeout in seconds
HEARTBIT_MCP_SERVERSComma-separated MCP server URLs
HEARTBIT_A2A_AGENTSComma-separated A2A agent URLs
HEARTBIT_REASONING_EFFORTReasoning effort level (high, medium, low, none)
HEARTBIT_ENABLE_REFLECTIONfalseEnable reflective reasoning (1 or true)
HEARTBIT_COMPRESSION_THRESHOLDToken threshold for context compression
HEARTBIT_MAX_TOOLS_PER_TURNMax tool calls per turn
HEARTBIT_TOOL_PROFILETool pre-filtering (conversational, standard, full)
HEARTBIT_MAX_IDENTICAL_TOOL_CALLSDoom loop detection threshold
HEARTBIT_SESSION_PRUNEfalseEnable session pruning of old tool results (1 or true)
HEARTBIT_RECURSIVE_SUMMARIZATIONfalseEnable cluster-then-summarize (1 or true)
HEARTBIT_REFLECTION_THRESHOLDCumulative importance threshold to trigger reflection
HEARTBIT_CONSOLIDATE_ON_EXITfalseConsolidate memories at session end (1 or true)
HEARTBIT_MEMORYMemory backend (in_memory or a PostgreSQL URL)
HEARTBIT_LSP_ENABLEDfalseEnable LSP integration (1 or true)
HEARTBIT_OBSERVABILITYproductionObservability mode (production, analysis, debug, off)
HEARTBIT_TELEGRAM_TOKENTelegram bot token (daemon mode)
HEARTBIT_API_KEYAPI key for daemon HTTP authentication
EXA_API_KEYExa AI API key (for websearch built-in tool)
RUST_LOGTracing filter (e.g. info, debug)

When HEARTBIT_PROVIDER is not set, the CLI auto-detects the provider based on which API key is available:

  1. If ANTHROPIC_API_KEY is set, uses the Anthropic provider
  2. If OPENROUTER_API_KEY is set, uses the OpenRouter provider

Variables documented as accepting 1 or true treat both values as enabled. Any other value (or unset) means disabled.

Terminal window
# Minimal standalone setup
export ANTHROPIC_API_KEY=sk-ant-...
heartbit "Analyze this codebase"
# Custom model with prompt caching
export HEARTBIT_MODEL=claude-opus-4-20250514
export HEARTBIT_PROMPT_CACHING=true
heartbit "Write a detailed report"
# With MCP servers and session pruning
export HEARTBIT_MCP_SERVERS="http://localhost:8000/mcp,http://localhost:8001/mcp"
export HEARTBIT_SESSION_PRUNE=1
heartbit "Use the available tools to complete the task"
# OpenRouter with custom tool timeout
export OPENROUTER_API_KEY=sk-or-...
export HEARTBIT_PROVIDER=openrouter
export HEARTBIT_TOOL_TIMEOUT=300
heartbit "Long-running analysis task"
# Daemon mode with Telegram
export HEARTBIT_TELEGRAM_TOKEN=bot123:ABC...
export HEARTBIT_API_KEY=my-secret-key
heartbit daemon --config daemon.toml