Skip to main content

CMEM Pro (manual / headless)

Use this when you already have a cmem.ai account and need to wire CMEM Pro without the interactive installer (CI, a second machine, or a box you SSH into). The usual path is still npx claude-mem install.
Never paste real cm_pro_… keys, setup tokens, or OpenRouter sk-or- keys into chat, tickets, or docs. The examples below are placeholders only. Keep ~/.claude-mem/settings.json mode 0600.

What the installer does

Three stages:
  1. Runtime — Bun/uv if needed, IDE plugin files, worker deps.
  2. Sign in — skipped for --provider claude, and for non-interactive runs without --provider (fresh install defaults to claude; an existing config keeps its provider). A non-interactive install that skipped sign-in prints an optional sign-in link as its last line; agents should show that link to the user rather than open it. Local installs contact cmem.ai once, at signup, to create the sign-in link, with a numbers-only usage summary (observation counts and token totals, no prompts, paths, or project names); nothing else is sent to cmem.ai. Otherwise the CLI does not ask for an email:
    • POST https://cmem.ai/api/installer/oauth/start with { source: "npx-installer", device_name: <hostname>, install_state: "fresh" | "update", usage_summary?: { window_days: 28, active_days, observations, memory_tokens, days: [{ d: "YYYY-MM-DD", obs, tokens }] } } (usage_summary is omitted when no local data can be read)
    • prints a device code XXXX-XXXX and opens authorization_url
    • polls https://cmem.ai/api/pro/trial/poll until authenticated
  3. Provider — CMEM Pro is pre-selected. Choosing it opens checkout_url (trial/claim), polls until status: "ready", then writes settings and restarts the worker.
--provider openrouter with a personal key is a different path: empty CLAUDE_MEM_OPENROUTER_BASE_URL (or https://openrouter.ai/api/v1). Never send a personal sk-or- key to https://cmem.ai/api/inference.

Settings the installer writes

Credentials are staged, then activated. File: ~/.claude-mem/settings.json.

Staged (sync + trial metadata)

Cloud sync is on only when the token, user id, and hub URL are all non-empty. See Cloud Sync.

Activated (this is what makes observations run)

The worker talks to cmem.ai through the generic OpenRouter client. There is no separate CMEM provider implementation.
Keep the cloud-sync trio from staging. memory_key and setup_token are often the same (cm_pro_…). If the poll returns a distinct memory_key, use that for CLAUDE_MEM_OPENROUTER_API_KEY and keep setup_token only on CLAUDE_MEM_CLOUD_SYNC_TOKEN.

Manual recipe (you already have tokens)

  1. From cmem.ai → Connect (or an installer pairing), copy setup_token, user_id, hub_url, and memory_key (if missing, use setup_token).
  2. Merge staged + activated keys into ~/.claude-mem/settings.json. Placeholders only:
  1. chmod 600 ~/.claude-mem/settings.json
  2. Restart the worker so it is not holding old in-memory provider/sync state:
The interactive installer stops the worker after it persists the provider for the same reason.
  1. Verify (port is CLAUDE_MEM_WORKER_PORT or ~/.claude-mem/.worker.port):
Expect health with provider openrouter, and sync configured: true plus hub.reachable: true.
  1. First real observation should store via model cmem-observer. Gateway success clears CLAUDE_MEM_PRO_FALLBACK_AT. A terminal gateway rejection (a spent allowance, an inactive subscription, or a refused key) sets that timestamp, memory falls back to the Anthropic plan, and the next session start relays the gateway’s own message and link.
Fallback is event-driven, not a calendar date. Do not treat CLAUDE_MEM_PRO_TRIAL_ENDS_AT as the switch. The switch is CLAUDE_MEM_PRO_FALLBACK_AT.

What not to mix

Never send a personal OpenRouter key to the cmem gateway.

Next steps