Code
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, copilot, or grok. |
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.
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.
| Variable | Channel |
|---|---|
TELEGRAM_BOT_TOKEN | Telegram |
DISCORD_BOT_TOKEN | Discord |
SLACK_APP_TOKEN, SLACK_BOT_TOKEN | Slack (Socket Mode) |
GITHUB_WEBHOOK_SECRET | GitHub webhook |
WHATSAPP_ACCESS_TOKEN, WHATSAPP_VERIFY_TOKEN, WHATSAPP_APP_SECRET | WhatsApp (Meta Cloud API) |
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. |
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.