D: π Want to interact with Google’s powerful Gemini AI directly from your terminal? This step-by-step guide will help absolute beginners install and use the Gemini CLI tool in just 5 minutes!
π§ Step 1: Install Python (If You Donβt Have It)
Gemini CLI runs on Python, so make sure you have it installed:
For Windows/Mac/Linux:
- Download Python from python.org (Choose Python 3.10+).
- Run the installer and check “Add Python to PATH” (important!).
- Verify installation by opening a terminal and typing:
python --version
(Should show something like
Python 3.11.4
)
π₯ Step 2: Install Gemini CLI
Open your terminal (Command Prompt / PowerShell / Terminal) and run:
pip install google-generativeai
(This installs the official Google Gemini Python package.)
π‘ Troubleshooting? If you see errors, try:
pip install --upgrade pip
π Step 3: Get Your Google API Key
- Go to Google AI Studio (makersuite.google.com).
- Sign in with your Google account.
- Click “Get API Key” and copy it. (Keep this secret!)
π Step 4: Ask Gemini Your First Question!
Create a new Python script (gemini_chat.py
) and paste this:
import google.generativeai as genai
# π Replace with your API key
genai.configure(api_key="YOUR_API_KEY_HERE")
# π Start chatting!
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content("Explain quantum computing like I'm 5 years old.")
print(response.text)
Run it in the terminal:
python gemini_chat.py
π Boom! You’ll see Gemini’s response instantly.
π‘ Example Queries to Try:
- “Write a Python function to calculate Fibonacci numbers.”
- “Best practices for React.js beginners.”
- “Explain how blockchain works in simple terms.”
π Next Steps:
- Explore Gemini Pro Vision for image analysis!
- Check out the official Gemini API docs.
- Automate tasks by integrating Gemini CLI into scripts!
β FAQ
Q: Is Gemini CLI free?
A: Yes, but Google has usage limits (check pricing page).
Q: Can I use Gemini CLI offline?
A: No, it requires an internet connection.
Q: How do I save chat history?
A: Youβll need to log responses to a file (e.g., open('log.txt', 'a').write(response.text)
).
π Now go play with AI magic! Try modifying the script, ask coding questions, or even generate poetry. The terminal is your playground!
π’ Stuck? Drop a comment below! Happy coding! π¨βπ»π©βπ»