CLI
Environment variables
The environment variables that control which backend memcode uses and how it behaves.
Backend selection
| Variable | Effect |
|---|---|
MEMCODE_API_TOKEN | Hosted gateway API token, set by memcode login. |
MEMCODE_API_URL | Override the gateway URL. Default is https://code.memcode.ai. |
MEMCODE_CREDENTIAL_SOURCE | Use a subscription you already have: claude, with aliases claude-sub and anthropic-sub, codex, or copilot. |
MEMCODE_ENDPOINT_URL | Point at any OpenAI-compatible endpoint such as Ollama or vLLM. |
MEMCODE_ENDPOINT_KEY | Key for that endpoint, if it needs one. |
MEMCODE_ENDPOINT_MODEL | Override the served model for an endpoint or subscription source. |
Provider keys
An exported ANTHROPIC_API_KEY or OPENAI_API_KEY activates that provider
directly, with no other setup.
The keys below are used when MEMCODE_ENDPOINT_URL points at the matching
provider's host:
| Variable | Provider |
|---|---|
GEMINI_API_KEY | Google Gemini |
XAI_API_KEY | xAI |
FIREWORKS_API_KEY | Fireworks |
GROQ_API_KEY | Groq |
MISTRAL_API_KEY | Mistral |
DEEPSEEK_API_KEY | DeepSeek |
TOGETHER_API_KEY | Together AI |
OPENROUTER_API_KEY | OpenRouter |
CEREBRAS_API_KEY | Cerebras |
ANTHROPIC_ADVISOR_MODEL overrides the model used by /advisor.
Behavior
| Variable | Effect |
|---|---|
MEMCODE_AUTO_UPDATE=off | Disable the daily background self-update. |
MEMCODE_TRACE | Set to a non-empty value to enable wire-trace logging, shown by /debug. |
MEMCODE_COMPACT_BUDGET | Override the context-compaction budget, or set off. |
MEMCODE_CONTEXT_SOFT_CAP | Lower the context ceiling for cost-capped setups. |
XDG_CONFIG_HOME | Relocate the global config and secrets directory. Otherwise ~/.config. |
CODEX_HOME | Where the Codex subscription login is read from. |
Set the backend variables in your shell profile to make a choice the default
across sessions, for example export MEMCODE_CREDENTIAL_SOURCE=claude.