Why use Gemini?
Cost savings
The free tier covers most individual usage patterns with no credit card required to get started.
Same observation quality
Gemini extracts observations using the same XML format as Claude, so output is compatible throughout.
Seamless fallback
Automatically falls back to Claude if Gemini is unavailable due to rate limiting or errors.
Hot-swappable
Switch providers without restarting the worker. Changes take effect on the next observation.
Getting a free API key
Open Google AI Studio
Go to the Google AI Studio API Key page and sign in with your Google account.
Create the key
Click Create API key, then choose an existing Google Cloud project or create a new one.
Available models
| Model | Free tier RPM | Notes |
|---|---|---|
gemini-2.5-flash-lite | 10 | Default — recommended for free tier (highest RPM) |
gemini-2.5-flash | 5 | Higher capability, lower rate limit |
gemini-3-flash-preview | 5 | Latest model, lower rate limit |
Rate limits with billing enabled
Enabling billing on your Google Cloud project does not incur charges within the free quota but dramatically raises rate limits:| Model | RPM | TPM |
|---|---|---|
gemini-2.5-flash-lite | 4,000 | 4M |
gemini-2.5-flash | 1,000 | 1M |
gemini-3-flash-preview | 1,000 | 1M |
Configuration
Settings reference
AI provider for observation extraction. Set to
gemini to use the Gemini API.Your Gemini API key. Takes precedence over the
GEMINI_API_KEY environment variable.Gemini model to use. Supported values:
gemini-2.5-flash-lite, gemini-2.5-flash, gemini-3-flash-preview.Set to
true to skip built-in rate-limit delays when billing is enabled on your Google Cloud project.Using the settings UI
Open the viewer
Go to http://localhost:37777 and click the gear icon to open Settings.
Manual configuration
Edit~/.claude-mem/settings.json:
settings.json
The settings file takes precedence over the
GEMINI_API_KEY environment variable.Switching providers
You can switch between Claude and Gemini at any time.- Via settings UI
- Via settings file
Open Settings
Open the viewer at http://localhost:37777 and click the gear icon.
- 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.
Fallback behavior
If Gemini encounters errors, Claude Mem automatically falls back to the Claude Agent SDK.Conditions that trigger fallback
Conditions that trigger fallback
- Rate limiting (HTTP 429)
- Server errors (HTTP 5xx)
- Network issues (connection refused, timeout)
Conditions that do not trigger fallback
Conditions that do not trigger fallback
- Missing API key: Logs a warning and uses Claude from the start (no mid-session switch).
- Invalid API key: Fails with an error rather than silently switching.
Troubleshooting
"Gemini API key not configured"
"Gemini API key not configured"
You need to supply the API key in one of two ways:
- Set
CLAUDE_MEM_GEMINI_API_KEYin~/.claude-mem/settings.json, or - Set the
GEMINI_API_KEYenvironment variable
Rate limiting
Rate limiting
Without billing enabled, Claude Mem enforces built-in delays between requests to stay within the free quota. Processing may be slower but remains within limits.To resolve rate limiting:
- Enable billing on your Google Cloud project and set
CLAUDE_MEM_GEMINI_BILLING_ENABLEDtotrue - Switch to
gemini-2.5-flash-lite, which has the highest free RPM (10 RPM) - Fall back to Claude as your primary provider while Gemini recovers
Lower observation quality
Lower observation quality
Claude typically produces slightly higher quality observations than Gemini. If observation quality is important for a specific project, consider using Claude as the provider for that work and Gemini for lower-stakes sessions where cost savings matter more.
Next steps
OpenRouter provider
Access 100+ models through OpenRouter’s unified API, including several free options.
Configuration reference
Full settings reference for all Claude Mem configuration options.