Skip to main content

Environment variables

OpenUsage reads two kinds of environment variables: runtime overrides (debug, paths, sockets) and API key envs referenced from accounts[].api_key_env. Both are listed below.

Runtime overrides

VariablePurpose
OPENUSAGE_DEBUGWhen set to any non-empty value, enables verbose logging to stderr (theme loader, daemon connection, integration installer, hook plumbing).
OPENUSAGE_BINOverride the binary path embedded in hook scripts. Useful when the binary lives at a non-standard location.
OPENUSAGE_TELEMETRY_SOCKETOverride the daemon Unix socket path. Equivalent to --socket-path, but inherited by every process (daemon, TUI, hooks).
OPENUSAGE_GITHUB_TOKENToken used for the in-app update check against GitHub. Optional; used to avoid anonymous rate limits.
OPENUSAGE_THEME_DIRColon-separated list (semicolon on Windows) of extra directories scanned for theme JSON files. See External themes.
OPENUSAGE_MOONSHOT_STATE_PATHOverride the path Moonshot's state file is read from.
XDG_CONFIG_HOMEOverride the config base directory (default ~/.config).
XDG_STATE_HOMEOverride the state base directory (default ~/.local/state).
CLAUDE_SETTINGS_FILEOverride the path to ~/.claude/settings.json. Used by the claude_code provider and integration.
CODEX_CONFIG_DIROverride the path to ~/.codex/. Used by the codex provider and integration.

API key environment variables

Each provider's account references its key via api_key_env — the name of the variable, not its value. Below are the conventional names used in configs/example_settings.json. You may override these; just keep api_key_env in sync.

ProviderDefault env var
OpenAIOPENAI_API_KEY
AnthropicANTHROPIC_API_KEY
OpenRouterOPENROUTER_API_KEY
GroqGROQ_API_KEY
MistralMISTRAL_API_KEY
DeepSeekDEEPSEEK_API_KEY
MoonshotMOONSHOT_API_KEY
xAIXAI_API_KEY
Z.AIZAI_API_KEY
Gemini APIGEMINI_API_KEY (also detects GOOGLE_API_KEY as an alias)
Alibaba CloudALIBABA_CLOUD_API_KEY
Ollama (cloud)OLLAMA_API_KEY

:::tip Adding a key without restarting The TUI reads env vars on startup. After exporting a new key, press q to quit and re-launch — or use the API Keys settings tab (, then 5) to enter the value at runtime, which writes it to your shell session for future processes only. :::

:::info GUI launches and shell rc files If OpenUsage is launched from Spotlight, the Dock, or another launcher that doesn't inherit your shell environment, it will still pick up keys exported in ~/.zshrc, ~/.bashrc, ~/.zshrc.d/*.zsh, fish config.fish, and similar files — the auto-detector parses them directly. Lines that contain shell substitutions ($VAR, $(...), backticks) are intentionally skipped. Run openusage detect to see exactly which file each adopted key came from. :::

CLI tool / local file providers

Some providers don't use API keys; they read local files or shell out to a tool binary. Their accounts entries use binary rather than api_key_env.

ProviderWhat it readsOverride
claude_code~/.claude.json, ~/.claude/stats-cache.json, ~/.claude/projects/**/*.jsonl, ~/.claude/settings.jsonCLAUDE_SETTINGS_FILE, plus binary field
codex~/.codex/sessions/*.jsonlCODEX_CONFIG_DIR, plus binary field
cursorLocal SQLite databases under ~/Library/Application Support/Cursor/ (or platform equivalent)binary field
gemini_cliGemini CLI's session filesbinary field (default gemini)
copilotgh copilot subcommandsbinary field (default gh)
ollama (local)http://127.0.0.1:11434base_url field
opencodeOpenCode session databinary field

Setting variables

Persistent

# zsh / bash
echo 'export OPENAI_API_KEY=sk-...' >> ~/.zshrc

# fish
set -Ux OPENAI_API_KEY sk-...

Per-process

OPENUSAGE_DEBUG=1 OPENUSAGE_TELEMETRY_SOCKET=/tmp/ou.sock openusage telemetry daemon run

In a service unit

For the daemon, set env vars via the launchd plist's EnvironmentVariables dictionary (macOS) or the systemd unit's Environment= lines (Linux). Reinstall via openusage telemetry daemon install after changing the unit if you want fresh defaults.

See also