memcode docs
CLI

Environment variables

The environment variables that control which backend memcode uses and how it behaves.

Backend selection

VariableEffect
MEMCODE_API_TOKENHosted gateway API token, set by memcode login.
MEMCODE_API_URLOverride the gateway URL. Default is https://code.memcode.ai.
MEMCODE_CREDENTIAL_SOURCEUse a subscription you already have: claude, with aliases claude-sub and anthropic-sub, codex, or copilot.
MEMCODE_ENDPOINT_URLPoint at any OpenAI-compatible endpoint such as Ollama or vLLM.
MEMCODE_ENDPOINT_KEYKey for that endpoint, if it needs one.
MEMCODE_ENDPOINT_MODELOverride 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:

VariableProvider
GEMINI_API_KEYGoogle Gemini
XAI_API_KEYxAI
FIREWORKS_API_KEYFireworks
GROQ_API_KEYGroq
MISTRAL_API_KEYMistral
DEEPSEEK_API_KEYDeepSeek
TOGETHER_API_KEYTogether AI
OPENROUTER_API_KEYOpenRouter
CEREBRAS_API_KEYCerebras

ANTHROPIC_ADVISOR_MODEL overrides the model used by /advisor.

Behavior

VariableEffect
MEMCODE_AUTO_UPDATE=offDisable the daily background self-update.
MEMCODE_TRACESet to a non-empty value to enable wire-trace logging, shown by /debug.
MEMCODE_COMPACT_BUDGETOverride the context-compaction budget, or set off.
MEMCODE_CONTEXT_SOFT_CAPLower the context ceiling for cost-capped setups.
XDG_CONFIG_HOMERelocate the global config and secrets directory. Otherwise ~/.config.
CODEX_HOMEWhere 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.

On this page