Skip to main content
VIJ integrates with Google Gemini to provide intelligent error analysis, root cause suggestions, and automated fix recommendations.

Overview

AI-powered features in VIJ include:

Error Summaries

Concise, human-readable explanations of what went wrong

Root Cause Analysis

Intelligent analysis of why the error occurred

Fix Suggestions

Actionable recommendations to resolve the issue

Pattern Detection

Identify recurring patterns across error groups

Getting Started

1

Get a Gemini API key

  1. Visit Google AI Studio
  2. Sign in with your Google account
  3. Click Get API Key
  4. Create a new API key
  5. Copy the key (starts with AIza...)
Google Gemini offers a generous free tier with 60 requests per minute. Most VIJ installations stay within free limits.
2

Configure VIJ Admin

Add the API key to your .env.local file:
.env.local
No code changes required. VIJ automatically detects the API key and enables AI features.
3

Restart the application

AI features are now enabled! Click any error in the dashboard to see AI analysis.
4

Verify AI is working

  1. Navigate to any error detail page
  2. Look for the “AI Analysis” section
  3. You should see:
    • AI Summary
    • Possible Cause
    • Suggested Fix
AI analysis may take 2-5 seconds on first load. Results are cached for performance.

AI Features in Detail

AI Summary

A concise explanation of the error in plain language. Example:
How it works:
  1. VIJ sends error message, stack trace, and context to Gemini
  2. Gemini analyzes the error
  3. Returns a human-readable summary
  4. Summary is cached in MongoDB for 7 days

Possible Cause

Root cause analysis explaining why the error occurred. Example:
Analysis includes:
  • Technical reasons for the error
  • Common scenarios that trigger this error
  • Dependencies or external factors
  • Code-level explanations

Suggested Fix

Actionable recommendations to resolve the error. Example:
Suggestions include:
  • Code examples
  • Best practices
  • Error handling improvements
  • Validation techniques

AI Analysis Workflow

Caching Strategy

AI analysis is cached to reduce API calls and improve performance:
  • Cache duration: 7 days
  • Cache key: Error fingerprint + Gemini model version
  • Cache invalidation: Manual or on model update
Benefits:
  • Faster load times for repeated errors
  • Reduced API costs
  • Offline access to previous analysis

Customizing AI Prompts

Customize how VIJ queries Gemini for better results.

Custom Prompt Template

Edit lib/gemini.ts to customize prompts:
lib/gemini.ts

Domain-Specific Prompts

Add custom context for your application:

Few-Shot Learning

Provide examples to improve AI responses:

AI Model Configuration

Model Selection

VIJ uses Gemini 1.5 Flash by default. You can configure different models:
lib/gemini.ts
Model Comparison:

Model Parameters

Fine-tune generation parameters:
Parameter Guide:
  • Temperature: Higher = more creative, lower = more focused
    • Use 0.3-0.5 for technical analysis
    • Use 0.7-0.9 for suggestions
  • maxOutputTokens: Control response length
    • Use 1024 for summaries
    • Use 2048 for detailed analysis

Advanced AI Features

Context-Aware Analysis

Include relevant context for better analysis:

Multi-Step Analysis

Perform deeper analysis with multiple AI calls:

Batch Analysis

Analyze multiple errors together for pattern detection:

API Usage and Costs

Rate Limits

Google Gemini free tier limits:
  • Requests per minute: 60
  • Requests per day: 1,500
  • Tokens per minute: 32,000
VIJ automatically handles rate limiting:

Cost Estimation

Gemini 1.5 Flash (free tier):
  • Input: Free up to 1M tokens/day
  • Output: Free up to 1M tokens/day
Typical VIJ usage:
  • Per error analysis: ~1,500 tokens
  • Daily budget: ~666 error analyses
  • Monthly cost: $0 (within free tier)
Paid tier (if needed):
  • Input: $0.075 per 1M tokens
  • Output: $0.30 per 1M tokens
  • 10,000 errors/month: ~$5-10

Monitoring Usage

Track API usage in VIJ Admin:

Error Handling

Handle AI failures gracefully:

Privacy and Security

Data Privacy

VIJ sends only error information to Gemini:
  • Error name, message, stack trace
  • Application metadata (appId, environment)
  • User-provided metadata
Not sent:
  • User PII (unless in metadata)
  • Authentication tokens
  • Database contents
  • Source code (unless in stack trace)

Opt-Out

Disable AI features without affecting core functionality:
UI automatically hides AI sections when disabled.

Data Retention

Control how long AI responses are cached:

Troubleshooting

Check:
  1. GEMINI_API_KEY is set in .env.local
  2. API key is valid (starts with AIza)
  3. Restart dev server after adding key
  4. Check browser console for errors
  5. Verify Gemini API quota
Test API key:
Error: 429 Too Many RequestsSolutions:
  • Increase cache duration to reduce API calls
  • Upgrade to paid tier for higher limits
  • Implement request queuing
  • Only analyze high-priority errors
Issue: AI suggestions are not helpfulImprovements:
  1. Add more context to prompts
  2. Use Gemini Pro instead of Flash
  3. Include code snippets in context
  4. Provide domain-specific information
  5. Use few-shot examples
Issue: Analysis takes too longSolutions:
  • Use Gemini Flash (fastest model)
  • Reduce maxOutputTokens
  • Enable caching
  • Pre-generate analysis for common errors

Best Practices

  • Track API usage daily
  • Set up billing alerts
  • Cache common errors
  • Use selective analysis
  • Don’t blindly trust suggestions
  • Review code examples
  • Test suggested fixes
  • Have humans verify critical fixes

Next Steps

Dashboard Features

View AI analysis in the dashboard

Error Grouping

Analyze grouped errors with AI

Analytics

Combine AI insights with analytics

Environment Variables

Configure Gemini API key