Documentation Index
Fetch the complete documentation index at: https://docs.claude-mem.ai/llms.txt
Use this file to discover all available pages before exploring further.
Custom Anthropic-Compatible Backends
When you use theclaude provider, claude-mem talks to the Anthropic API through the Claude Agent SDK. By default, the SDK targets the official Anthropic endpoint, but it honors the standard ANTHROPIC_BASE_URL environment variable. That means you can route claude-mem at any Anthropic-protocol-compatible backend — for example a corporate gateway, a regional bridge, or a third-party provider that exposes an Anthropic-shaped API — without changing any claude-mem source code.
This page documents how to persist a custom base URL so claude-mem’s worker uses it consistently. It does not add an OpenAI-compatible provider, and it does not auto-detect the bridge configuration from your shell — both of those are tracked separately in issue #2196. For now, configuration is manual.
When to Use This
UseANTHROPIC_BASE_URL if you need claude-mem’s observation worker to talk to:
- A corporate Anthropic gateway (proxy in front of
api.anthropic.com) - A regional Anthropic deployment (e.g. AWS Bedrock or GCP Vertex via an Anthropic-compatible shim)
- A third-party provider that bridges its API to the Anthropic protocol
How the Plumbing Works
The flow is intentionally simple:- You write the credential to
~/.claude-mem/.env. EnvManager.loadClaudeMemEnv()reads that file (src/shared/EnvManager.ts:67).buildIsolatedEnv()copiesANTHROPIC_BASE_URLinto the worker’s spawn environment alongsideANTHROPIC_API_KEY(src/shared/EnvManager.ts:164).ClaudeProvider.startSession()spawns the Claude Agent SDK with that isolated env (src/services/worker/ClaudeProvider.ts:115). The SDK readsANTHROPIC_BASE_URLnatively — claude-mem does not parse or rewrite it.
Configuration
Step 1: Edit ~/.claude-mem/.env
The credentials file is a plain KEY=VALUE env file at ~/.claude-mem/.env (mode 0600). Add or update the ANTHROPIC_BASE_URL line:
0700 and the file to 0600 automatically on the next worker write.
Step 2: Pick a Compatible Model
CLAUDE_MEM_MODEL (in ~/.claude-mem/settings.json) is passed straight through to the SDK. The model name must be one your bridge accepts — claude-mem does not translate names.
Step 3: Restart the Worker
Credentials are loaded when the worker spawns the SDK, so a restart is required after you edit.env:
Worked Example: Corporate Gateway
Suppose your team runshttps://anthropic-proxy.internal.example.com in front of api.anthropic.com for audit and rate-limit purposes. The proxy accepts the same protocol and the same model names.
~/.claude-mem/.env:
~/.claude-mem/settings.json:
Verifying
After restarting, watch the worker logs for the next observation flush:SDK Starting SDK query line followed by Response received. If the gateway rejects the request, the SDK error surfaces verbatim in worker-error.log — there is no silent fallback to the public Anthropic endpoint.
Limitations and Gotchas
- No model-name translation. If your bridge expects
glm-4.7andCLAUDE_MEM_MODELisclaude-haiku-4-5-20251001, the request will fail. PinCLAUDE_MEM_MODELto a name your bridge recognizes. ANTHROPIC_API_KEYis required even if your gateway uses a different auth header. The SDK refuses to spawn without it; many gateways either pass the value through or accept any non-empty placeholder. Check your gateway’s docs.ANTHROPIC_BASE_URLfrom your shell is not inherited.ANTHROPIC_API_KEYis in the BLOCKED_ENV_VARS list (src/shared/EnvManager.ts:10) to prevent accidental billing on a shell-leaked key —ANTHROPIC_BASE_URLis not blocked, but it must still be set in~/.claude-mem/.envfor the worker to pick it up reliably across restarts. Do not rely on shell exports.- No auto-detection. If you have already configured
ANTHROPIC_BASE_URL,ANTHROPIC_DEFAULT_HAIKU_MODEL, etc. for Claude Code itself, claude-mem will not read those today. Mirror the relevant values into~/.claude-mem/.envand~/.claude-mem/settings.json. See issue #2196 for the auto-detect feature request.
Related
- Configuration — All claude-mem settings
- OpenRouter Provider — OpenAI-compatible bridge for non-Anthropic protocols
- Gemini Provider — Native Gemini API alternative

