A JavaScript chatbot powered by Google Gemini API.
- 🤖 Real-time chat interface with Gemini
- 💬 Conversation history management
- 🎨 Modern, responsive UI (Gemini-inspired theme)
- 📱 Mobile-friendly design
- 🔄 Clear conversation history
- 🎯 Status indicator for Gemini connection
- Node.js 16+ (recommend latest LTS)
- A Google AI Studio API key with access to Gemini (e.g.,
gemini-2.5-flash,gemini-2.5-pro)
- Install dependencies
npm install- Configure environment
Create .env (use .env.example as a template):
PORT=3000
GEMINI_API_KEYS=key1,key2,key3,key4,key5
GEMINI_MODEL=gemini-2.5-flashKeep your real API key in
.env; never commit it..gitignorealready excludes.env.
- Run the app
npm startOpen http://localhost:3000 and chat.
PORT– server port (default: 3000)GEMINI_API_KEY– required Gemini API key (keep private)GEMINI_MODEL– model name, e.g.gemini-2.5-flash,gemini-2.5-pro
- Start the server:
npm start - Visit
http://localhost:3000 - Chat in the UI; clear history with the Clear button
-
POST
/api/chat- Request:
{ "message": "hello" } - Response:
{ "success": true, "message": "...", "history": [...] }
- Request:
-
POST
/api/clear- Clears conversation history
-
GET
/api/status- Returns Gemini connectivity, configured model, and available models
- Cannot connect to Gemini / 403: verify
GEMINI_API_KEYand that your key has access to the chosen model. - Model not available / 404: set
GEMINI_MODELto one listed inavailable_modelsfrom/api/status(e.g.,gemini-2.5-flash). - Quoted keys: ensure
.envdoes not wrap the API key in quotes.
.
├── server.js # Express server and API routes (Gemini)
├── package.json # Node dependencies
├── .env # Local secrets (not committed)
├── .env.example # Template with placeholders
└── public/
└── index.html # Frontend UI
- Do not commit
.envor real keys. Use placeholders in docs and.env.example. .gitignorealready excludes.envandnode_modules/.
MIT