API Keys Configuration

Configure essential API keys through the visual config UI to enable ChatRAG's full functionality.

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:

  1. Visit platform.openai.com
  2. Sign up or log in to your account
  3. Navigate to API Keys section
  4. Generate a new secret key
  5. Add billing information (pay-as-you-go pricing)

Environment variable:

OPENAI_API_KEY=sk-proj-...

Recommended model:

OPENAI_EMBEDDING_MODEL=text-embedding-3-small

OpenRouter API KeyRECOMMENDED

Access 100+ AI models from multiple providers through a unified API. Provides the best flexibility for model selection.

How to get it:

  1. Visit openrouter.ai
  2. Create an account
  3. Navigate to Keys section in dashboard
  4. Generate a new API key
  5. 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:

  1. Visit cloud.llamaindex.ai
  2. Sign up for a free account
  3. Navigate to API Keys section
  4. 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_URL
  • NEXT_PUBLIC_SUPABASE_ANON_KEY
  • SUPABASE_SERVICE_ROLE_KEY (server-only secret; never expose in browser)
  • OPENAI_API_KEY (required for embeddings)
  • OPENROUTER_API_KEY or direct OpenAI models
  • NEXT_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=...

Applying Configuration

After configuring your API keys through the Config UI:

  1. Click "Save Settings" in the Config UI
  2. Values are written to .env.local
  3. Restart your development server: Ctrl+C then npm run dev
  4. Verify configuration is loaded by checking the console for any missing key warnings