Environment Setup Guide
Environment Setup Guide
Step 1: Get OpenAI API Key
- Go to https://platform.openai.com/api-keys
- Sign up or log in
- Click “Create new secret key”
- Copy the key (starts with
sk-) - ⚠️ Save it immediately - you won’t see it again!
Step 2: Create Vector Store (First Time)
- Navigate to the backend directory:
cd rag-backend - Install dependencies:
npm install - Create
.envfile:cp .env.example .env - Add your API key to
.env:OPENAI_API_KEY=sk-your-actual-key-here - Run ingestion script:
npm run ingest - The script will:
- Upload all PDFs from
../files/ - Create a vector store
- Print a
VECTOR_STORE_ID(starts withvs-)
- Upload all PDFs from
- Add the vector store ID to
.env:VECTOR_STORE_ID=vs-your-store-id-here
Step 3: Set Up GitHub Secrets (for GitHub Actions)
If you want automatic PDF ingestion when you add new papers:
- Go to your GitHub repo → Settings → Secrets and variables → Actions
- Click “New repository secret”
- Add these secrets:
OPENAI_API_KEY: Your OpenAI API keyVECTOR_STORE_ID: The vector store ID from step 2
Step 4: Update Chatbot Widget
Edit _includes/chatbot.html and change this line:
const API_URL = "https://your-backend.onrender.com/api/chat";
Replace your-backend.onrender.com with your actual backend URL after deployment.
Step 5: Deploy Backend
See README.md for deployment instructions (Render, Railway, etc.)
Cost Monitoring
Monitor your usage at: https://platform.openai.com/usage
Set up billing alerts to avoid surprises!