Google Gemini
Gemini is the recommended LLM provider for SmarterAvatar, offering excellent RAG support through native File Search and competitive pricing.
Why Gemini?
- Native File Search - Built-in RAG without external vector databases
- 1M token context - Process entire documents without chunking
- Cost effective - Lower per-token costs than competitors
- Multimodal - Supports text, images, and files
Setup
1. Get API Key
- Go to Google AI Studio
- Sign in with your Google account
- Navigate to Get API key
- Create a new API key or use existing
2. Configure Environment
LLM_PROVIDER=gemini
GEMINI_API_KEY=AIzaSy...your-api-key
GEMINI_MODEL=gemini-3.0-flash
3. (Optional) Configure File Search
For RAG with native File Search:
GEMINI_FILE_SEARCH_STORE_NAME=your-knowledge-base
Available Models
| Model | Context | Best For | Cost (Input) |
|---|---|---|---|
gemini-3.0-flash | 1M tokens | Most use cases | $0.50/1M |
gemini-2.5-pro | 1M tokens | Complex tasks | $1.25/1M |
gemini-2.5-flash | 1M tokens | Budget option | $0.15/1M |
RAG with File Search
Gemini's File Search provides built-in RAG capabilities:
Upload Documents
Use the admin panel or CLI to upload documents:
pnpm upload-gemini-file path/to/document.pdf
Supported formats:
- TXT
- Markdown
- HTML
- DOCX
Automatic Features
- Chunking - Documents automatically split for retrieval
- Embeddings - Generated and indexed by Gemini
- Citations - Responses include source references
File Management
View and manage uploaded files:
pnpm list-gemini-files
Or via the Admin Panel → Knowledge Base section.
Configuration Options
Full configuration reference:
# Required
GEMINI_API_KEY=AIzaSy...
# Model selection
GEMINI_MODEL=gemini-3.0-flash
# File Search (RAG)
GEMINI_FILE_SEARCH_STORE_NAME=my-kb
# API version (usually auto-detected)
GEMINI_API_VERSION=v1beta
Troubleshooting
"API key not valid"
- Verify your API key at Google AI Studio
- Check for extra spaces or characters in
.env - Ensure the key has the correct permissions
"Model not found"
- Use the full model name (e.g.,
gemini-3.0-flash) - Check available models with
pnpm list-gemini-models
"File Search not working"
- Ensure
GEMINI_API_VERSION=v1betais set - Wait a few minutes after uploading for indexing
- Check file upload status in admin panel
Cost Estimation
For a typical 3-minute session (4 interactions) with Gemini 3.0 Flash:
| Component | Tokens | Cost |
|---|---|---|
| Input (system + RAG + user) | ~10,000 | $0.005 |
| Output (responses) | ~1,200 | $0.0036 |
| Total | ~11,200 | ~$0.01 |
Gemini remains cost-effective compared to Claude/GPT-4 for most use cases.