memcode docs
Code

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, copilot, or grok.
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.

Gateway channels

These are the bot credentials for the gateway. They use each platform's own conventional variable name, and memcode gateway setup writes them to your global .env for you, so you rarely set them by hand.

VariableChannel
TELEGRAM_BOT_TOKENTelegram
DISCORD_BOT_TOKENDiscord
SLACK_APP_TOKEN, SLACK_BOT_TOKENSlack (Socket Mode)
GITHUB_WEBHOOK_SECRETGitHub webhook
WHATSAPP_ACCESS_TOKEN, WHATSAPP_VERIFY_TOKEN, WHATSAPP_APP_SECRETWhatsApp (Meta Cloud API)

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.

You rarely need to set the backend variables yourself: choices made through the first-run wizard or memcode auth are remembered across sessions. The variables are there for scripts and CI.

On this page