Skip to main content
Google Gemini offers powerful AI models with a generous free tier, making it an excellent choice for code analysis with Vibrant CLI without any upfront costs.

Why Gemini?

  • Free tier - Generous limits for developers at no cost
  • Fast - Quick response times for rapid analysis
  • High quality - Excellent code understanding capabilities
  • No credit card required - Start analyzing immediately

Get an API key

1

Visit Google AI Studio

Go to aistudio.google.com and sign in with your Google account.
2

Get API key

Click โ€œGet API keyโ€ in the left sidebar.
3

Create key

Click โ€œCreate API keyโ€ and select a Google Cloud project (or create a new one).
4

Copy your key

Your key will look like AIza.... Copy it and keep it secure.
No credit card is required for the free tier. You can start using Gemini immediately.

Setup

Set the environment variable in your shell:
export GOOGLE_GENERATIVE_AI_API_KEY="AIza..."
To make it permanent, add it to your shell profile:
# Add this line to your shell profile
export GOOGLE_GENERATIVE_AI_API_KEY="AIza..."

Option 2: Alternative environment variable

You can also use the shorter GEMINI_API_KEY variable:
export GEMINI_API_KEY="AIza..."

Option 3: .env file

Create a .env file in your project directory:
.env
GOOGLE_GENERATIVE_AI_API_KEY=AIza...
# Or alternatively:
# GEMINI_API_KEY=AIza...
Add .env to your .gitignore to prevent committing your API key.

Option 4: Configuration file

Create a vibrant.config.js file:
vibrant.config.js
module.exports = {
  provider: 'gemini',
  // API key will be read from environment variable
};

Usage

Run Vibrant with Gemini:
# Auto-detect provider (if GOOGLE_GENERATIVE_AI_API_KEY is set)
vibrant . --ai

# Explicitly specify Gemini
vibrant . --ai --provider gemini

Available models

Vibrant uses gemini-2.0-flash-lite by default for optimal speed and quality.
  • Context: 1M tokens
  • Cost: Free tier available
  • Speed: Very fast
  • Quality: Excellent for code analysis
  • Best for: Daily development, CI/CD pipelines
  • Free tier: 15 RPM, 1M TPM, 1500 RPD
  • Context: 1M tokens
  • Cost: Free tier available
  • Speed: Very fast
  • Quality: High performance
  • Best for: Fast analysis of large codebases
  • Free tier: 15 RPM, 1M TPM, 1500 RPD
  • Context: 2M tokens
  • Cost: Free tier available
  • Speed: Fast
  • Quality: Superior reasoning
  • Best for: Complex analysis, large projects
  • Free tier: 2 RPM, 32K TPM, 50 RPD
RPM = Requests per minute, TPM = Tokens per minute, RPD = Requests per day

Change the model

Set the GEMINI_MODEL environment variable:
export GEMINI_MODEL="gemini-1.5-pro"
vibrant . --ai --provider gemini
Or in your .env file:
.env
GOOGLE_GENERATIVE_AI_API_KEY=AIza...
GEMINI_MODEL=gemini-1.5-pro

Free tier limits

ModelRequests/minTokens/minRequests/day
gemini-2.0-flash-lite151M1500
gemini-1.5-flash151M1500
gemini-1.5-pro232K50
These limits are generally sufficient for:
  • Regular development workflows
  • Small to medium team usage
  • CI/CD pipeline integration
  • Learning and experimentation
If you need higher limits, you can enable billing in Google Cloud Console. Pay-as-you-go pricing is very affordable.

Example output

vibrant . --ai --provider gemini
๐Ÿ”ฎ Vibrant Analysis
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

๐Ÿ“ก AI Analysis (gemini:gemini-2.0-flash-lite)

๐Ÿ“Š Token Optimization:
   Original: 38,000 tokens
   Summarized: 15,200 tokens
   Savings: 60.0%

โœ” Analysis complete

๐Ÿ“‹ Summary:
The codebase has solid structure but contains security issues
that need immediate attention. Error handling could be improved
for better debugging and user experience.

๐Ÿ” Key Findings:
  โ€ข API credentials hardcoded in 2 files
  โ€ข 8 empty catch blocks that swallow errors
  โ€ข Debug console.log statements left in production code

๐Ÿ’ก Recommendations:
  โ€ข Move all secrets to environment variables
  โ€ข Add proper error logging and monitoring
  โ€ข Remove debug code before deployment
  โ€ข Consider implementing a centralized logging service

โœ• 2 errors ยท โš  8 warnings ยท 75 files ยท 6s

Troubleshooting

Error: API key not found

Gemini API error: API key not valid
Solution: Set the GOOGLE_GENERATIVE_AI_API_KEY or GEMINI_API_KEY environment variable:
export GOOGLE_GENERATIVE_AI_API_KEY="AIza..."

Error: Quota exceeded

Gemini API quota exceeded. Free tier limit reached.

Options:
  โ€ข Wait a few minutes and try again
  โ€ข Try Ollama (free, local): vibrant . --ai --provider ollama
  โ€ข Enable billing: https://aistudio.google.com/
Solutions:
  1. Wait and retry: Free tier resets per minute/day. Wait a few minutes.
  2. Use Ollama: Switch to local models: vibrant . --ai --provider ollama
  3. Use OpenRouter: Try free models: vibrant . --ai --provider openrouter
  4. Enable billing: Add payment method for higher limits (very affordable)

Error: Resource exhausted

Gemini API error: resource exhausted
Solution: Youโ€™ve hit the rate limit. Vibrant automatically retries, but if it persists:
# Wait 60 seconds and try again
sleep 60 && vibrant . --ai --provider gemini

# Or use a different provider
vibrant . --ai --provider openrouter

Best practices

1

Use for daily development

Geminiโ€™s free tier is perfect for frequent code analysis during development.
2

Respect rate limits

For large projects, analyze in smaller batches or use specific file patterns.
3

Enable billing for teams

If multiple team members are using the same API key, consider enabling pay-as-you-go billing.
4

Use in CI/CD

Geminiโ€™s speed and free tier make it ideal for automated code quality checks.

CI/CD integration

For GitHub Actions:
.github/workflows/code-quality.yml
name: Code Quality

on: [push, pull_request]

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: '20'
      
      - name: Run Vibrant with Gemini
        run: npx vibrant-cli . --ai --provider gemini
        env:
          GOOGLE_GENERATIVE_AI_API_KEY: ${{ secrets.GOOGLE_GENERATIVE_AI_API_KEY }}
Add GOOGLE_GENERATIVE_AI_API_KEY as a secret in your repository settings.
If you need higher limits, enable billing:
1

Enable billing

Visit Google Cloud Console and add a payment method.
2

Very affordable pricing

  • gemini-2.0-flash-lite: ~$0.01 per 1M tokens
  • gemini-1.5-flash: ~$0.04 per 1M tokens
  • gemini-1.5-pro: ~$1.25 per 1M tokens
3

Significantly higher limits

Paid tier removes most rate limiting for typical usage.

Next steps

AI providers overview

Compare all available providers

Ollama setup

Try local models for unlimited free usage

Build docs developers (and LLMs) love