Skip to main content

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

  1. Go to Google AI Studio
  2. Sign in with your Google account
  3. Navigate to Get API key
  4. 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

For RAG with native File Search:

GEMINI_FILE_SEARCH_STORE_NAME=your-knowledge-base

Available Models

ModelContextBest ForCost (Input)
gemini-3.0-flash1M tokensMost use cases$0.50/1M
gemini-2.5-pro1M tokensComplex tasks$1.25/1M
gemini-2.5-flash1M tokensBudget option$0.15/1M

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:

  • PDF
  • 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=v1beta is 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:

ComponentTokensCost
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.