Common Issues
Common problems and their solutions when working with AIQ.
Installation Issues
Environment Variables Not Loading
Symptom: Application crashes with "Environment variable not defined" errors.
Solution:
- Ensure
.env.localexists in the project root (not in subdirectories) - Restart the development server after adding environment variables
- Verify variable names match exactly (case-sensitive)
# Stop the server
Ctrl+C
# Restart
npm run dev
Database Connection Failed
Symptom: "Failed to connect to Supabase" or timeout errors.
Solution:
- Check Supabase project status in dashboard
- Verify
NEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_ANON_KEYare correct - Check your internet connection
- Ensure RLS policies are applied:
npx supabase db push
Migration Errors
Symptom: Migrations fail with constraint or syntax errors.
Solution:
- Check if migrations were already applied:
npx supabase migration list
- If stuck, reset and reapply:
# Be careful - this drops all data!
npx supabase db reset
npx supabase db push
- Check for migration file conflicts (duplicate timestamps)
API Key Issues
Invalid API Key Format
Symptom: Provider returns "Invalid API key" or authentication errors.
Solution:
-
Verify key format matches provider requirements:
- Anthropic:
sk-ant-api03-...(80+ characters) - OpenAI:
sk-...(51 characters) - Google: Alphanumeric, 39 characters
- Perplexity:
pplx-...
- Anthropic:
-
Check for extra spaces, quotes, or newlines:
# Incorrect (has quotes)
ANTHROPIC_API_KEY="sk-ant-..."
# Correct (no quotes)
ANTHROPIC_API_KEY=sk-ant-...
- Regenerate key from provider dashboard if necessary
API Key Not Found in Settings
Symptom: Settings page shows "No API keys configured".
Solution:
- Add keys through the Settings UI first
- Keys are encrypted and stored per organization
- Environment variable keys (
ANTHROPIC_API_KEYetc.) are only used as fallback
Query Execution Issues
Rate Limit Exceeded
Symptom: Queries fail with "Rate limit exceeded" or 429 errors.
Solution:
-
Slow down request rate - wait 1-2 seconds between queries
-
Check provider dashboard for rate limits:
- Anthropic Tier 1: 50 requests/minute
- OpenAI Tier 1: 60 requests/minute
- Gemini: 60 requests/minute (free tier)
-
Upgrade API tier if needed for higher limits
Model Not Found (404)
Symptom: "Model not found" or 404 errors when querying.
Solution:
-
Check if model ID is current (models get deprecated):
- ✅ Current:
claude-sonnet-4-5-20250929 - ❌ Deprecated:
claude-3-5-sonnet-20241022
- ✅ Current:
-
Update
lib/api/llm-client-factory.tswith valid model IDs -
Rebuild and redeploy
Timeout Errors
Symptom: Queries timeout after 30-60 seconds.
Solution:
- Increase timeout in Vercel (Pro plan required for >60s)
- Simplify prompts - shorter prompts = faster responses
- Use faster models (e.g.,
claude-3-5-haiku-20241022instead of opus) - Check provider status pages for outages
UI/Display Issues
Analytics Not Updating
Symptom: Dashboard shows old data or "0 queries".
Solution:
- Hard refresh the page:
Cmd+Shift+R(Mac) orCtrl+Shift+R(Windows) - Check if queries actually executed (check Supabase dashboard)
- Verify RLS policies allow reads:
-- Run in Supabase SQL Editor
SELECT * FROM llm_queries LIMIT 10;
- Check browser console for errors (F12)
Dark Mode Issues
Symptom: Text not visible or styling broken.
Solution:
- Ensure Tailwind CSS is configured correctly
- Check if
dark:classes are applied - Clear browser cache and reload
- Verify Tailwind config in
tailwind.config.ts
Performance Issues
Slow Page Load
Symptom: Pages take 5+ seconds to load.
Solution:
- Check database query performance in Supabase dashboard
- Verify indexes are created (migrations should handle this)
- Limit large queries with pagination
- Enable Next.js caching for static content
High API Costs
Symptom: Unexpected high bills from LLM providers.
Solution:
- Review query history in AIQ analytics
- Check for accidental batch executions
- Set spending limits in provider dashboards:
- OpenAI: Billing → Usage Limits
- Anthropic: Billing → Budget Alerts
- Use cheaper models for testing (Gemini free tier, or Perplexity)
Deployment Issues
Vercel Build Fails
Symptom: Deployment fails with TypeScript or build errors.
Solution:
- Check build logs for specific errors
- Verify all environment variables are set in Vercel
- Run build locally first:
npm run build
- Fix TypeScript errors before deploying
- Ensure all dependencies are in
package.json
Environment Variables Not Working in Production
Symptom: Works locally but fails in production.
Solution:
- Set environment variables in Vercel dashboard (Project Settings → Environment Variables)
- Redeploy after adding variables
- Use
NEXT_PUBLIC_prefix for client-side variables - Check variable names match exactly (case-sensitive)
Data Issues
Missing Citations
Symptom: Queries execute but no citations are extracted.
Solution:
- Check if provider response actually contains citations
- Verify citation extraction logic in
lib/utils/citation-extractor.ts - Some providers (like base GPT-4) don't always include citations
- Use Perplexity for guaranteed citation-rich responses
Duplicate Queries in History
Symptom: Same query appears multiple times.
Solution:
- Check if page is being refreshed/reloaded during execution
- Verify database constraints are applied
- Clear test data if needed:
DELETE FROM llm_queries WHERE prompt LIKE '%test%';
Getting More Help
If you're still stuck:
- Check GitHub Issues: github.com/your-repo/issues
- Review Documentation: See other docs sections for detailed guides
- Check Provider Status:
- Review Logs:
- Browser console (F12)
- Vercel logs (if deployed)
- Supabase logs (Database → Logs)