API Keys Configuration
Configure essential API keys through the visual config UI to enable ChatRAG's full functionality.
Using the Config UI
http://localhost:3333. Run npm run config to access it.Essential API Keys
These keys are required for core functionality and must be configured before running ChatRAG.
OpenAI API KeyREQUIRED
Required for document embeddings and reasoning models. Embeddings are essential for the RAG system to work.
How to get it:
- Visit platform.openai.com
- Sign up or log in to your account
- Navigate to API Keys section
- Generate a new secret key
- Add billing information (pay-as-you-go pricing)
Environment variable:
OPENAI_API_KEY=sk-proj-...Recommended model:
OPENAI_EMBEDDING_MODEL=text-embedding-3-smallOpenRouter API KeyRECOMMENDED
Access 100+ AI models from multiple providers through a unified API. Provides the best flexibility for model selection.
How to get it:
- Visit openrouter.ai
- Create an account
- Navigate to Keys section in dashboard
- Generate a new API key
- Add credits or connect payment method
Environment variable:
OPENROUTER_API_KEY=sk-or-v1-...Available Models Include:
- •OpenAI GPT-4, GPT-4o, o1, o3
- •Anthropic Claude 3.5 Sonnet, Claude 4.1 Opus
- •Google Gemini 2.5 Flash, Gemini Thinking
- •Meta Llama 4 Maverick
- •DeepSeek R1 (reasoning)
LlamaCloud API KeyREQUIRED
Required for PDF/DOCX processing and RAG functionality. Powers the document parsing and chunking system.
How to get it:
- Visit cloud.llamaindex.ai
- Sign up for a free account
- Navigate to API Keys section
- Generate a new secret key
Environment variable:
NEXT_PUBLIC_LLAMA_CLOUD_API_KEY=llx-...What it enables:
- Intelligent PDF parsing with layout preservation
- DOCX and other document format support
- Smart semantic chunking for optimal retrieval
- Table and image extraction
Minimum Required Configuration
To run ChatRAG locally, you must have:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEY(server-only secret; never expose in browser)OPENAI_API_KEY(required for embeddings)OPENROUTER_API_KEYor direct OpenAI modelsNEXT_PUBLIC_LLAMA_CLOUD_API_KEY
Optional API Keys
These keys enable additional features and can be configured as needed.
FAL.ai API Key
For image, video, and 3D generation
FAL_API_KEY=...Replicate API Token
Alternative for media generation
REPLICATE_API_TOKEN=...ElevenLabs API Key
For text-to-speech and voice features
ELEVENLABS_API_KEY=...Exa API Key
For web search functionality
EXA_API_KEY=...Polar PaymentsRECOMMENDED
Easiest payment setup for SaaS subscriptions
POLAR_ACCESS_TOKEN=...
NEXT_PUBLIC_POLAR_PRICE_ID_STARTER=...
NEXT_PUBLIC_POLAR_CHECKOUT_STARTER=...
NEXT_PUBLIC_POLAR_PRICE_ID_PRO=...
NEXT_PUBLIC_POLAR_CHECKOUT_PRO=...
NEXT_PUBLIC_POLAR_PRICE_ID_ENTERPRISE=...
NEXT_PUBLIC_POLAR_CHECKOUT_ENTERPRISE=...Stripe Keys
Alternative payment processing
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=...
STRIPE_SECRET_KEY=...GitHub OAuth
For GitHub authentication
NEXT_PUBLIC_GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...Security Best Practices
- Variables prefixed with
NEXT_PUBLIC_are exposed to the browser - All other variables remain server-side only
- Never commit
.env.localto version control - Service role keys should never be exposed client-side
- Rotate keys regularly and use separate keys for development/production
Applying Configuration
After configuring your API keys through the Config UI:
- Click "Save Settings" in the Config UI
- Values are written to
.env.local - Restart your development server:
Ctrl+Cthennpm run dev - Verify configuration is loaded by checking the console for any missing key warnings
Pro Tip
npm run config) running alongside your dev server for quick configuration changes during development.