LLM providers

shmem needs an LLM for QA synthesis (generating grounded answers). Capture works without one; only shmem ask needs it.

How shmem install picks one

It takes the first of these it finds, records it in ~/.shmem/.env, and says which on its ✓ answers via … line:

  1. an existing SHMEM_QA_PROVIDER setting
  2. an API key in your environment: ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY (or their SHMEM_-prefixed forms)
  3. Claude Code's own cloud settings: CLAUDE_CODE_USE_BEDROCK=1 → Bedrock, CLAUDE_CODE_USE_VERTEX=1 with ANTHROPIC_VERTEX_PROJECT_ID → Claude on Vertex AI
  4. a signed-in Claude Code or Codex CLI, used headlessly — see claude-cli / codex-cli below
  5. only when none of the above exists and this machine doesn't sync with a hosted server: a running Ollama with a model pulled (shmem's default qwen2.5:1.5b if present, otherwise the first non-embedding model). Install warns that local answers are slower and weaker — see ollama below

If none is found, install prints a note instead, and shmem ask shows the same note until you add one. You don't need to run install again afterwards: when nothing is configured, shmem ask (and the ask_memory MCP tool) runs the same search and saves what it finds to ~/.shmem/.env.

shmem needs an LLM to answer questions, and found none on this machine.
Memories are saved either way; answers start working once you add one:

  - an API key: add ANTHROPIC_API_KEY=... (or OPENAI_API_KEY,
    GEMINI_API_KEY, OPENROUTER_API_KEY) to ~/.shmem/.env
  - or sign in to Claude Code or Codex, and shmem will answer through it
  - or, to keep everything on this machine, a local model: install Ollama
    and run `ollama pull qwen2.5:1.5b`. On most laptops its answers are slow
    and noticeably worse than the options above.

shmem picks it up the next time you ask.

With no API key or agent sign-in but a hosted remote configured, shmem ask (and the ask_memory MCP tool) answers through the hosted server's QA instead of a local Ollama.

To choose explicitly: shmem install --provider <name>, or set SHMEM_QA_PROVIDER in ~/.shmem/.env.

Provider details

anthropic — Best answer quality (94% on LongMemEval with Sonnet 4). Get a key at console.anthropic.com and add ANTHROPIC_API_KEY=sk-ant-... to ~/.shmem/.env.

openai — OpenAI API, or any OpenAI-compatible service (Together AI, Groq, Fireworks). Set SHMEM_OPENAI_BASE_URL for non-OpenAI hosts:

# OpenAI directly
SHMEM_QA_PROVIDER=openai SHMEM_QA_MODEL=gpt-5.6-terra

# Together AI (open-weight models)
SHMEM_QA_PROVIDER=openai SHMEM_OPENAI_BASE_URL=https://api.together.xyz/v1 \
  OPENAI_API_KEY=$TOGETHER_API_KEY SHMEM_QA_MODEL=meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8

gemini — Google Gemini API. Requires an API key from aistudio.google.com.

claude-cli / codex-cli — No API key needed: shmem asks your signed-in Claude Code (claude -p, Haiku by default) or Codex (codex exec) headlessly, with the agent's hooks, MCP servers and tools turned off so the question isn't itself captured. Each answer uses your agent plan and takes a few seconds; an API key is faster. shmem install picks one only when no API key is set, and says so.

These providers need network access from the command running shmem. Inside a Codex command sandbox that marks its network as off (CODEX_SANDBOX_NETWORK_DISABLED=1), shmem still tries the agent, since an allowlisted sandbox can reach it; if the call fails the way a cut-off network does, shmem ask says so. Run the question from a regular terminal outside that session, or add an API key to ~/.shmem/.env and run shmem install --provider openai (or anthropic, gemini, openrouter) in an environment with network access. An API key does not bypass sandbox network restrictions. Installation warns that answers may fail when it selects or keeps an agent-CLI provider in that sandbox.

ollama — Free, fully private, runs on your hardware, at a cost in quality: the models a typical laptop can run answer slowly and noticeably worse than the cloud options above, so choose it when keeping everything on the machine matters more. A GPU with room for a larger model narrows the gap. Requires Ollama — install from ollama.ai/download or curl -fsSL https://ollama.com/install.sh | sh on Linux:

ollama pull qwen2.5:1.5b

With the daemon running, shmem install --provider ollama configures it (or plain shmem install, when nothing else is available).

mock — No LLM at all. recall_memory / shmem query still work for keyword search, but ask will not synthesize answers.