- Visit Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the generated API key
Create a file called .env in the server folder with this content:
# Gemini API Configuration
GEMINI_API_KEY=your-actual-gemini-api-key-here
# Server Configuration
PORT=3001
NODE_ENV=developmentReplace your-actual-gemini-api-key-here with your real Gemini API key.
cd server
npm installnpm run devYou should see:
✅ Gemini API key configured
🚀 Chatbot API server running on port 3001
🔗 Test your API key: http://localhost:3001/api/test
curl http://localhost:3001/api/testIn another terminal:
npm run dev- ✅ Backend: Now uses Google's Gemini AI instead of OpenAI
- ✅ API: Uses
@google/generative-ailibrary - ✅ Authentication: Uses Gemini API key
- ✅ Chat Format: Properly formatted for Gemini's chat API
- Context-Aware: AI understands the specific programming problem
- Code Analysis: Can review and provide feedback on user code
- Progressive Hints: Provides hints at different levels
- Real-time Chat: Interactive conversation with the AI tutor
- Make sure you created the
.envfile in theserverfolder - Verify your API key is correct
- Check that the file is named exactly
.env(with the dot)
- Verify your Gemini API key is valid
- Check your Google AI Studio account has sufficient quota
- Ensure you're using the correct API key format
- The server is configured to accept requests from
localhost:5173andlocalhost:3000 - If using a different port, update the CORS configuration in
server/api/chatbot.js
- Gemini API keys are free to create
- You get generous free tier usage
- The API is generally faster than OpenAI
- Supports multiple languages and code analysis