A minimal Python console chat application using Google's Gemini API.
Software Engineer who teaches programming on YouTube.
- 📸 Instagram: https://www.instagram.com/sergiecode
- 🧑🏼💻 LinkedIn: https://www.linkedin.com/in/sergiecode/
- 📽️ YouTube: https://www.youtube.com/@SergieCode
- 😺 GitHub: https://github.com/sergiecode
- 👤 Facebook: https://www.facebook.com/sergiecodeok
- 🎞️ TikTok: https://www.tiktok.com/@sergiecode
- 🕊️ Twitter: https://twitter.com/sergiecode
- 🧵 Threads: https://www.threads.net/@sergiecode
- 💬 Simple console chat with Google Gemini AI
- 🔐 Secure API key management using
.envfile - ⚡ Fast and lightweight
- 🛡️ Basic error handling
- Python 3.7 or higher
- Google Gemini API key
-
Install dependencies:
pip install -r requirements.txt -
Set up your API key:
copy .env.template .env
Then edit
.envand add your actual API key -
Run the chat:
python chat_bot.py
Or double-click
run_chat.bat
- Type messages to chat with Gemini
- Type
quit,exit, orbyeto exit - Press
Ctrl+Cto force exit
gemini-api-chatbol-python/
├── chat_bot.py # Main chat application
├── .env # Your API key (create from template)
├── .env.template # Template for API key setup
├── .gitignore # Git ignore file
├── requirements.txt # Python dependencies
├── run_chat.bat # Windows launcher
└── README.md # This file
- Copy
.env.templateto.env - Add your Gemini API key to the
.envfile:GEMINI_API_KEY=your_actual_api_key_here
google-generativeai: Official Google Generative AI Python clientpython-dotenv: Load environment variables from.envfile
- API Key Error: Make sure
.envfile exists with correct API key - Rate Limit: Wait a few minutes if you see quota exceeded errors
- Import Error: Run
pip install -r requirements.txt
Created with ❤️ by Sergie Code