SCMD now supports Google Gemini API for generating embeddings, providing a reliable cloud-based alternative to Ollama.
- ✅ Always available (cloud-based)
- ✅ No local installation required
- ✅ High-quality embeddings
- ✅ Fast and reliable
- ✅ Free tier available
- Visit Google AI Studio
- Create a new API key
- Copy the key
# Gemini API Configuration (Primary)
GEMINIAPI=your_api_key_here
GEMINIMODEL=text-embedding-004
# Embedding dimension (must match your PostgreSQL table)
EMBEDDING_DIM=384text-embedding-004(Recommended) - Latest embedding modelembedding-001- Previous generation
SCMD uses a fallback system:
- Gemini API (Primary) - If
GEMINIAPIis configured - Ollama (Fallback) - If Gemini fails or unavailable
- Text-only (Last resort) - If no embedding provider available
# Automatically generates embeddings using Gemini
scmd --save "docker ps -a" "List all containers"
# Output:
# ✓ Gemini API available (model: text-embedding-004, embedding_dim: 384)
# ✓ Generated embedding using Gemini API
# returned: ( true )scmd --cli
# Output:
# ✓ Gemini API available (model: text-embedding-004, embedding_dim: 384)
# ✓ Ollama available at localhost:11434 (model: llama2, embedding_dim: 384)When searching, SCMD will:
- Try traditional keyword search first
- If no good matches, use Gemini for vector similarity search
- Return semantically similar commands
scmd --search "container management"
# Will find commands like:
# - docker ps -a
# - docker container ls
# - kubectl get pods| Feature | Gemini | Ollama |
|---|---|---|
| Availability | Always (cloud) | Requires local server |
| Setup | API key only | Install + model download |
| Speed | Fast | Depends on hardware |
| Quality | High | Varies by model |
| Cost | Free tier available | Free (local compute) |
Gemini's text-embedding-004 produces 768-dimensional embeddings by default.
SCMD automatically adjusts to your configured dimension:
# Your PostgreSQL table has vector(384)
EMBEDDING_DIM=384SCMD will:
- Truncate 768 → 384 dimensions automatically
- No quality loss for command search use case
- Check your API key is correct
- Verify API key has embedding permissions
- Check if you've exceeded free tier limits
- You've hit rate limits
- Wait a few seconds and retry
- Consider upgrading to paid tier
If Gemini fails, SCMD automatically tries Ollama:
⚠ Gemini embedding failed: API error, trying Ollama...
✓ Generated embedding using Ollama
If both fail, commands are saved without embeddings:
⚠ No embedding provider available, saving without vector
Commands without embeddings still work with traditional text search!
- 1,500 requests per day
- More than enough for personal use
- Adding 1 command = 1 embedding request
- Searching = 1 embedding request per search
- ~100 commands/day = well within free tier
If you were using Ollama, no changes needed:
- Add
GEMINIAPIto.env - Gemini becomes primary
- Ollama remains as fallback
- Existing embeddings still work
- Use Gemini for production - More reliable
- Keep Ollama as fallback - For offline scenarios
- Set EMBEDDING_DIM=384 - Good balance of speed/quality
- Monitor API usage - Stay within free tier
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=scmd_user
DB_PASS=secure_password
DB_NAME=scmd_db
TB_NAME=scmd
# Gemini (Primary)
GEMINIAPI=AIzaSyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
GEMINIMODEL=text-embedding-004
# Ollama (Fallback)
OLLAMA=localhost
MODEL=llama2
# Embeddings
EMBEDDING_DIM=384✅ Gemini API is now the default embedding provider ✅ More reliable than Ollama (always available) ✅ Easy setup (just API key) ✅ Automatic fallback to Ollama if needed ✅ Free tier sufficient for most users ✅ No code changes required - just update .env