Skip to main content

Configuration

Fine-tune your AEO/GEO Analytics installation with these configuration options.

Environment Variables Reference

All configuration happens through environment variables in .env.local:

Required Variables

# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...your-anon-key...

These are required for the application to run. Without them, database operations will fail.

LLM Provider API Keys

Add at least one provider to execute queries:

# Anthropic Claude
ANTHROPIC_API_KEY=sk-ant-...

# OpenAI GPT-4
OPENAI_API_KEY=sk-...

# Google Gemini
GOOGLE_AI_API_KEY=...

# Perplexity
PERPLEXITY_API_KEY=pplx-...
Provider Selection
  • Claude: Best for citation-rich responses, excellent reasoning
  • GPT-4: Industry standard, balanced responses
  • Gemini: Good for diverse perspectives
  • Perplexity: Optimized for search-like responses with citations

You can add all four and choose per query execution.

LLM Provider Setup

Anthropic Claude

  1. Go to console.anthropic.com
  2. Sign up or log in
  3. Navigate to API Keys
  4. Click Create Key
  5. Copy the key (starts with sk-ant-)
  6. Add to .env.local: ANTHROPIC_API_KEY=sk-ant-...

Models Used: claude-sonnet-4-5-20250929

Cost: ~$0.003 per query (3 cents per 10 queries)

OpenAI GPT-4

  1. Go to platform.openai.com
  2. Sign up or log in
  3. Add payment method (required for API access)
  4. Navigate to API Keys
  5. Click Create new secret key
  6. Copy the key (starts with sk-)
  7. Add to .env.local: OPENAI_API_KEY=sk-...

Models Used: gpt-4-turbo-preview

Cost: ~$0.01 per query (10 cents per 10 queries)

Google Gemini

  1. Go to aistudio.google.com
  2. Sign in with Google account
  3. Click Get API Key
  4. Create a new project or select existing
  5. Copy the API key
  6. Add to .env.local: GOOGLE_AI_API_KEY=...

Models Used: gemini-1.5-pro

Cost: Free tier available (60 requests/minute)

Perplexity

  1. Go to docs.perplexity.ai
  2. Sign up for API access
  3. Navigate to API settings
  4. Generate API key (starts with pplx-)
  5. Add to .env.local: PERPLEXITY_API_KEY=pplx-...

Models Used: llama-3.1-sonar-large-128k-online

Cost: ~$0.001 per query (1 cent per 10 queries)

Supabase Configuration

Row Level Security (RLS)

AEO/GEO Analytics uses public read access for analytics data. The migrations automatically set up RLS policies.

Verify RLS Policies:

  1. Open Supabase dashboard → AuthenticationPolicies
  2. Check that these policies exist:
    • Enable read access for all users on llm_queries
    • Enable read access for all users on llm_responses
    • Enable read access for all users on citations
    • Similar policies for query library tables

If missing, run migrations again:

npx supabase db push

Database Indexes

Migrations include optimized indexes for:

  • Query lookups by provider and date
  • Citation searches by domain
  • Query set filtering by industry and tags

No manual index creation needed.

Connection Pooling

Supabase automatically handles connection pooling. Default settings work for most use cases.

Next.js Configuration

Build Configuration

The next.config.ts includes:

const config: NextConfig = {
// Server-side rendering for dynamic data
// Static optimization where possible

// Environment variables are automatically loaded from .env.local
};

No changes needed for default setup.

TypeScript Configuration

Strict mode enabled in tsconfig.json:

{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true
}
}

This ensures type safety throughout the application.

Cost Management

Estimated Costs Per Provider

ProviderCost per QueryCost per 100 Queries
Perplexity$0.001$0.10
Claude$0.003$0.30
GPT-4$0.010$1.00
GeminiFree*Free*

*Gemini: Free tier includes 60 requests/minute, 1500 requests/day

Cost Optimization Tips

  1. Use Gemini for testing: Free tier is generous
  2. Batch queries: Execute 20-50 at once for systematic analysis
  3. Choose providers strategically:
    • High-value queries → Claude or GPT-4
    • Testing/exploration → Gemini or Perplexity
  4. Monitor usage: Check provider dashboards monthly

Set Spending Limits

OpenAI:

  • Dashboard → BillingUsage Limits
  • Set monthly cap (e.g., $10/month)

Anthropic:

  • Dashboard → BillingBudget Alerts
  • Set notification thresholds

Security Best Practices

Environment Variables

Do:

  • Keep .env.local in .gitignore (already configured)
  • Use different API keys for dev/production
  • Rotate keys periodically
  • Use environment-specific keys in Vercel

Don't:

  • Commit .env.local to version control
  • Share API keys in Slack/Discord
  • Use production keys in local development
  • Hard-code keys in application code

Supabase Security

The application uses anon/public key (safe for client-side):

  • Read-only access via RLS policies
  • No write operations without authentication
  • Keys can be safely exposed in frontend code
warning

The service_role key (admin access) should never be used or exposed in the application. Only use anon/public key.

Development vs Production

Local Development

Use .env.local for local environment:

# .env.local (local development)
NEXT_PUBLIC_SUPABASE_URL=https://local-dev-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...local-key...
ANTHROPIC_API_KEY=sk-ant-...dev-key...

Production (Vercel)

Set environment variables in Vercel dashboard:

  1. Go to Project SettingsEnvironment Variables
  2. Add each variable:
    • NEXT_PUBLIC_SUPABASE_URL
    • NEXT_PUBLIC_SUPABASE_ANON_KEY
    • ANTHROPIC_API_KEY
    • etc.
  3. Choose environment: Production, Preview, or Development
  4. Click Save
tip

Use different Supabase projects for production and development to avoid data mixing.

Testing Your Configuration

Verify Environment Variables

Create a test page to verify (dev only):

npm run dev

Navigate to /dashboard/execute and check API Key Status section:

  • Configured = API key detected and valid format
  • ⚠️ Not Configured = API key missing or invalid

Test Database Connection

Run a test query:

npm run dev

Go to Analytics page:

  • If you see "Total Queries: 0" → Database connected ✅
  • If you see error → Check Supabase credentials

Test LLM Providers

Execute test queries from the Execute page to verify each provider works.

Advanced Configuration

Custom Database Schema

If you need custom fields:

  1. Create a new migration file:
npx supabase migration new add_custom_field
  1. Edit migration in supabase/migrations/
  2. Apply migration:
npx supabase db push

Custom LLM Models

To use different models, edit lib/api/ client files:

// lib/api/claude-client.ts
const MODEL = 'claude-sonnet-4-5-20250929'; // Change model here

Rebuild after changes:

npm run build

Troubleshooting Configuration

Environment Variable Not Found

Symptom: NEXT_PUBLIC_SUPABASE_URL is not defined

Solution:

  1. Verify .env.local exists in project root
  2. Restart dev server: Ctrl+C then npm run dev
  3. Check for typos in variable names

API Key Invalid

Symptom: Invalid API key error when executing

Solution:

  1. Verify key format (no spaces, newlines, quotes)
  2. Regenerate key from provider dashboard
  3. Update .env.local
  4. Restart server

Database Connection Failed

Symptom: Failed to connect to Supabase

Solution:

  1. Check Supabase project status (dashboard)
  2. Verify URL and anon key are correct
  3. Check RLS policies are enabled
  4. Run migrations: npx supabase db push

Next Steps

Configuration complete! Move on to: