Gemini Provider
Claude-mem supports Google’s Gemini API as an alternative to the Claude Agent SDK for extracting observations from your sessions. This can significantly reduce costs since Gemini offers a generous free tier.Why Use Gemini?
- Cost savings: The free tier covers most individual usage patterns
- Same quality: Gemini extracts observations using the same XML format as Claude
- Errors throw clearly: 429s, 5xx, and network failures throw — leaving messages pending so they can be retried
- Hot-swappable: Switch providers without restarting the worker
Getting a Free API Key
- Go to the Google AI Studio API Key page
- Sign in with your Google account
- Accept the Terms of Service and privacy policies
- Click the Create API key button
- Choose a Google Cloud project or create a new one
- Copy and securely store the generated API key
Configuration
Settings
Using the Settings UI
- Open the worker URL printed on startup
- Click the gear icon to open Settings
- Under AI Provider, select Gemini
- Enter your Gemini API key
- Optionally select a different model
Manual Configuration
Edit~/.claude-mem/settings.json:
Available Models
Provider Switching
You can switch between Claude and Gemini at any time:- No restart required: Changes take effect on the next observation
- Conversation history preserved: When switching mid-session, the new provider sees the full conversation context
- Seamless transition: Both providers use the same observation format
Switching via UI
- Open Settings in the viewer
- Change the AI Provider dropdown
- The next observation will use the new provider
Switching via Settings File
Error Behavior
If Gemini is selected and the API errors, claude-mem logs the failure and re-throws so the message stays pending for later retry. There is no Claude SDK fallback — earlier docs claimed automatic Claude fallback, but the wiring was never actually engaged in production (#2087). To switch providers, changeCLAUDE_MEM_PROVIDER in settings.
Throwing conditions:
- Rate limiting (HTTP 429)
- Server errors (HTTP 5xx)
- Network issues (connection refused, timeout)
- 4xx errors other than 429
- Missing API key
Troubleshooting
”Gemini API key not configured”
Either:- Set
CLAUDE_MEM_GEMINI_API_KEYin~/.claude-mem/settings.json, or - Set the
GEMINI_API_KEYenvironment variable
Rate Limiting
Google has two rate limit tiers for free usage: Without billing (API key only):
Claude-mem enforces these limits automatically with built-in delays between requests. Processing may be slower but stays within limits.
With billing enabled (still free tier):
If you hit rate limits:
- Claude-mem automatically falls back to Claude SDK
- Or switch back to Claude as your primary provider
Observation Quality
If observations seem lower quality with Gemini:- Note that Claude typically produces slightly higher quality observations
- Consider using Gemini for cost savings and Claude for important projects
Next Steps
- Configuration - Full settings reference
- Getting Started - Basic usage guide
- Troubleshooting - Common issues

