<<<<<<< HEAD
Gemini API Chatbot
This project provides simple command-line chatbots for Google's Gemini API in both Python and Node.js.
Features
- Chat with Gemini using the latest high-throughput model (
gemini-2.5-flash) - Works in both Python and Node.js
- Easy to run from the terminal
Requirements
- Node.js v18+ (for Node.js chatbot)
- Python 3.9+ (for Python chatbot)
- A valid Gemini API key from Google AI Studio
Setup
- Clone or download this repository.
- Install dependencies:
- For Python:
- For Node.js:
- Set your Gemini API key:
- The API key is currently set directly in both
chatbot.pyandchatbot.jsfor demonstration. - Recommended for production: Use a
.envfile to store your API key securely.
Using a .env File (Recommended)
- Create a file named
.envin your project root: - Update your code:
- For Python, make sure you have these lines at the top:
And use
os.getenv("GEMINI_API_KEY")to access the key. - For Node.js, add this at the top:
And use
process.env.GEMINI_API_KEYto access the key. - Remove the hardcoded API key from your code for security.
Usage
Python
Run the chatbot with:
Type your message and press Enter. Typeexit to quit.
Node.js
Run the chatbot with:
Type your message and press Enter. Typeexit to quit.
File Overview
chatbot.py: Python CLI chatbot using the Gemini API.chatbot.js: Node.js CLI chatbot using the Gemini API.requirements.txt: Python dependencies.package.json: Node.js dependencies.README.md: This documentation file.
Security Note
Never share your API key publicly. For production, always use environment variables or a .env file to keep your key secure.
References
Gemini API Chatbot (USES Gemini API)
This utility uses the Gemini API for AI chat. All other logic and data are managed locally for learning and experimentation.
This project provides simple command-line chatbots for Google's Gemini API in both Python and Node.js.
Features
- Chat with Gemini using the latest high-throughput model (
gemini-2.5-flash) - Works in both Python and Node.js
- Easy to run from the terminal
- Beginner-friendly: All code is commented for learning
Requirements
- Node.js v18+ (for Node.js chatbot)
- Python 3.9+ (for Python chatbot)
- A valid Gemini API key from Google AI Studio
Setup
- Clone or download this repository.
- Install dependencies:
- For Python:
- For Node.js:
- Set your Gemini API key:
- The API key is currently set directly in both
chatbot.pyandchatbot.jsfor demonstration. - Recommended for production: Use a
.envfile to store your API key securely.
Usage Workflow (Step-by-Step)
- Run the chatbot:
- For Python:
- For Node.js:
- Type your message and press Enter. Type
exitto quit.
Educational Notes
- How does it work? The chatbot sends your message to the Gemini API and prints the response.
- How is the code structured? Each function is commented to explain its purpose. The code is designed for easy modification.
- How can you extend it? Try adding conversation history, or integrating with a GUI!
Security Note
Never share your API key publicly. For production, always use environment variables or a .env file to keep your key secure.
License
MIT
References
- Gemini API Quickstart (Python)
- Gemini API Rate Limits
8944b09 (Initial commit: Comprehensive Python & JS Finance Utilities for Beginners (API & API-free, with detailed docs))