Summary
Add claude-code as an LLM provider option, allowing users with Claude Pro/Max subscriptions to use their subscription for LLM-assisted features (rerank, entity refinement) without requiring a separate API key.
Motivation
Currently, MemPalace supports three LLM providers (llm_client.py):
ollama — local models (default)
openai-compat — OpenAI-compatible endpoints
anthropic — requires API key
Users who already pay for Claude Pro/Max subscriptions cannot leverage their existing authentication for MemPalace's LLM features. They must either:
- Set up Ollama locally
- Pay for a separate Anthropic API key
- Use a third-party OpenAI-compatible service
Proposed Solution
Add a claude-code provider that uses the Claude Agent SDK (claude-agent-sdk) to make LLM calls through the user's existing Claude CLI authentication (claude auth login).
Reference Implementation
Hindsight has already implemented this pattern successfully:
Key implementation details from Hindsight:
from claude_agent_sdk import query, ClaudeAgentOptions
# Simple call
async for message in query(prompt=user_content, options=options):
# process response
# With tools
async with ClaudeSDKClient(options=options) as client:
await client.query(user_content)
async for message in client.receive_response():
# process response
Use Cases
- Rerank (Hybrid + LLM): Users can get ≥99% R@5 using their Claude subscription instead of 98.4% with Hybrid v4 alone
- Entity refinement (
mempalace init --llm): Better entity classification without Ollama setup
- Future LLM features: Any upcoming LLM-assisted functionality
Implementation Scope
- Add
ClaudeCodeProvider class to mempalace/llm_client.py
- Add
claude-code to provider selection logic
- Add dependency:
claude-agent-sdk (optional, only needed if using this provider)
- Update CLI flags documentation
Additional Context
- Claude Agent SDK:
pip install claude-agent-sdk
- Requires user to run
claude auth login once
- No API key management needed
- Works with Claude Pro ($20/mo) and Max ($100/mo) subscriptions
Summary
Add
claude-codeas an LLM provider option, allowing users with Claude Pro/Max subscriptions to use their subscription for LLM-assisted features (rerank, entity refinement) without requiring a separate API key.Motivation
Currently, MemPalace supports three LLM providers (
llm_client.py):ollama— local models (default)openai-compat— OpenAI-compatible endpointsanthropic— requires API keyUsers who already pay for Claude Pro/Max subscriptions cannot leverage their existing authentication for MemPalace's LLM features. They must either:
Proposed Solution
Add a
claude-codeprovider that uses the Claude Agent SDK (claude-agent-sdk) to make LLM calls through the user's existing Claude CLI authentication (claude auth login).Reference Implementation
Hindsight has already implemented this pattern successfully:
hindsight-api-slim/hindsight_api/engine/providers/claude_code_llm.pyclaude_agent_sdk.query()for simple calls andClaudeSDKClientfor tool callingclaude auth logincredentials — no API key neededKey implementation details from Hindsight:
Use Cases
mempalace init --llm): Better entity classification without Ollama setupImplementation Scope
ClaudeCodeProviderclass tomempalace/llm_client.pyclaude-codeto provider selection logicclaude-agent-sdk(optional, only needed if using this provider)Additional Context
pip install claude-agent-sdkclaude auth loginonce