AI Integration: Google Gemini Setup
Set up Gemini API and CLI for free, powerful AI-powered research assistance
Why Gemini for Academic Research?
Google's Gemini API offers the most generous free tier in the AI landscape, making it an ideal choice for students and researchers working with budget constraints.
Free Tier Comparison
| Feature | Gemini Free | ChatGPT Free | Elicit Free |
|---|---|---|---|
| Requests/day | 25 | Limited chat | 5,000 credits (one-time) |
| Context window | 2M tokens | 8K tokens | N/A |
| Cost | $0/year | $0/year | Free trial only |
| Research features | Grounding, files | Chat only | Specialized |
Massive Context Window: Gemini's 2 million token context window equals approximately 1,500 pages of text. This means you can feed entire research papers to Gemini and ask comprehensive questions without splitting the document.
Setup Process
Get Your API Key
Visit ai.google.dev and navigate to Google AI Studio.
Click "Get API key in Google AI Studio" in the top navigation.
Create a new API key and copy it to your clipboard. Keep this key secure - treat it like a password.
Install Gemini CLI
Choose the installation method that matches your development environment:
Install the Gemini CLI globally using npm:
npm install -g @google/gemini-cliAdd your API key to your shell profile:
echo 'export GEMINI_API_KEY="your-key-here"' >> ~/.zshrc
source ~/.zshrcReplace ~/.zshrc with ~/.bashrc if using bash instead of zsh.
Install the Google Generative AI library:
pip install google-generativeaiAdd your API key to your shell profile:
echo 'export GEMINI_API_KEY="your-key-here"' >> ~/.zshrc
source ~/.zshrcReplace ~/.zshrc with ~/.bashrc if using bash instead of zsh.
Verify Installation
Test your setup by running a simple query:
gemini "Hello! Can you help with academic research?"Expected response: Gemini will introduce itself and confirm it can assist with research tasks like paper summarization, literature review, and methodology analysis.
Student Bonus - Unlimited Access: If you're a student, join the GitHub Student Developer Pack to get unlimited Gemini API access until June 2026 with no rate limits or quotas.
Research Use Cases
Paper Summarization
Quickly extract methodology and findings from research papers:
gemini "Summarize the methodology and key findings" \
--file ~/Zotero/papers/smith_2024.pdfLiterature Comparison
Compare methodologies across multiple papers:
gemini "Compare the methodologies in these three papers" \
--file paper1.pdf,paper2.pdf,paper3.pdfResearch Question Brainstorming
Generate research questions based on literature review:
gemini "Based on this literature review, suggest 5 research questions that address identified gaps" \
--file literature-review.mdCitation Extraction
Extract all citations from a paper in a specific format:
gemini "Extract all citations from this paper and format them as APA 7th edition" \
--file research-paper.pdfMethodology Analysis
Analyze research methodology for strengths and limitations:
gemini "Analyze the research methodology in this paper. What are its strengths and potential limitations?" \
--file methodology-section.pdfBest Practices
Context Management: Gemini's 2M token window allows feeding entire papers, but start with specific sections (abstract, methodology) for faster responses.
Iterative Queries: Break complex analysis into multiple queries rather than one massive prompt for better quality results.
File Format Support: Gemini accepts PDF, TXT, MD, and DOCX files directly through the CLI.
API Rate Limits: Free tier allows 25 requests per day. Plan your research workflow to maximize these queries.
Security: Never commit API keys to git repositories. Always use environment variables.
Next Steps
Ready-to-use Gemini scripts are available in the course repository at 02-code-examples/gemini-scripts/.
These scripts include:
- Batch paper summarization
- Automated literature review generation
- Research gap identification
- Citation network analysis
Proceed to the next chapter to learn how to integrate Gemini with your Zotero workflow for automated research assistance.