You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: I'd open this as a PR but the repo restricts cross-fork PRs to collaborators ("An owner of this repository has limited the ability to open a pull request to users that are collaborators on this repository"). Filing as an issue per that policy. Branch with the proposed change is pushed and ready at: https://github.com/DuanneBesso/claude-mem/tree/feat/openrouter-base-url-override
Summary
Adds an optional CLAUDE_MEM_OPENROUTER_BASE_URL setting that overrides the hardcoded https://openrouter.ai/api/v1 base URL when set. Backward-compatible: when the value is empty or unset, the existing URL is used unchanged.
Use cases
Self-hosted gateways. Route OpenRouter-shaped requests through LiteLLM, Portkey, or any other OpenAI-compatible proxy on http://localhost:4000/v1.
Local-only inference for privacy-sensitive deployments. Run compaction against local Ollama (or LM Studio) via a local OpenAI-compatible proxy. Compacted memory snippets — which often include code, conversation context, and HIPAA-adjacent material in clinical/healthcare deployments — never leave the machine.
Corporate proxies. Route through an enterprise gateway that requires a fixed URL.
Testing / mocking. Point at a local fixture server during integration tests.
Implementation
New resolveOpenRouterApiUrl() reads CLAUDE_MEM_OPENROUTER_BASE_URL from settings.json first, falls back to process.env, then to the existing public URL.
Strips trailing slashes before appending /chat/completions so both http://localhost:4000/v1 and http://localhost:4000/v1/ work.
Resolved once at module load — matches the existing static-constant pattern; no per-request overhead.
Backward compatibility
Zero breaking change. Existing users with no override see byte-identical behavior. The default-defaults dictionary just gains one new empty-string field.
Files touched
src/services/worker/OpenRouterProvider.ts — read base URL via resolveOpenRouterApiUrl()
src/shared/SettingsDefaultsManager.ts — add field to SettingsDefaults type + DEFAULTS object
src/ui/viewer/types.ts — add optional field to viewer settings type
src/ui/viewer/constants/settings.ts — add empty-string default for the viewer
src/ui/viewer/hooks/useSettings.ts — pass-through in viewer's settings load
Tested against a real local LiteLLM proxy (http://localhost:4000/v1) routing to Ollama-hosted Qwen2.5-Coder. claude-mem successfully:
Issues OpenAI-format POST /chat/completions requests to the new URL
Receives well-formed responses
Stores observations in the local SQLite + Chroma vector store as expected
Logs OpenRouter API usage {model=local-coder, ...} (the local model alias) without errors
When CLAUDE_MEM_OPENROUTER_BASE_URL is empty or unset, behavior is identical to the pre-patch state — verified by reverting the env var and confirming requests go to https://openrouter.ai/api/v1/chat/completions as before.
Add me as a collaborator so I can open the PR through your normal flow
Or I can copy the diff inline if you prefer that format
Happy to add a unit test assertion for the new default field if you want — left tests untouched to keep the change small. Thanks for maintaining claude-mem!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Summary
Adds an optional
CLAUDE_MEM_OPENROUTER_BASE_URLsetting that overrides the hardcodedhttps://openrouter.ai/api/v1base URL when set. Backward-compatible: when the value is empty or unset, the existing URL is used unchanged.Use cases
http://localhost:4000/v1.Implementation
resolveOpenRouterApiUrl()readsCLAUDE_MEM_OPENROUTER_BASE_URLfrom settings.json first, falls back toprocess.env, then to the existing public URL./chat/completionsso bothhttp://localhost:4000/v1andhttp://localhost:4000/v1/work.Backward compatibility
Zero breaking change. Existing users with no override see byte-identical behavior. The default-defaults dictionary just gains one new empty-string field.
Files touched
src/services/worker/OpenRouterProvider.ts— read base URL viaresolveOpenRouterApiUrl()src/shared/SettingsDefaultsManager.ts— add field toSettingsDefaultstype + DEFAULTS objectsrc/ui/viewer/types.ts— add optional field to viewer settings typesrc/ui/viewer/constants/settings.ts— add empty-string default for the viewersrc/ui/viewer/hooks/useSettings.ts— pass-through in viewer's settings loadDiff: main...DuanneBesso:claude-mem:feat/openrouter-base-url-override
Verification
Tested against a real local LiteLLM proxy (
http://localhost:4000/v1) routing to Ollama-hosted Qwen2.5-Coder. claude-mem successfully:POST /chat/completionsrequests to the new URLOpenRouter API usage {model=local-coder, ...}(the local model alias) without errorsWhen
CLAUDE_MEM_OPENROUTER_BASE_URLis empty or unset, behavior is identical to the pre-patch state — verified by reverting the env var and confirming requests go tohttps://openrouter.ai/api/v1/chat/completionsas before.Maintainer-friendly merge options
If you'd like to merge this:
git fetch https://github.com/DuanneBesso/claude-mem.git feat/openrouter-base-url-override && git cherry-pick <commit>(one commit, SHA81731a3)Happy to add a unit test assertion for the new default field if you want — left tests untouched to keep the change small. Thanks for maintaining claude-mem!
All reactions