A beginner-friendly project built during MLH Global Hack Week: Agents.
In this workshop, we use Node.js and Google Gemini to build increasingly capable AI agents — from a simple Gemini request to conversation memory, vision, and tool calling.
- Connect Node.js to the Gemini API
- Build an interactive Gemini chat agent
- Give an agent conversation memory
- Use Gemini's multimodal capabilities to understand images
- Give Gemini tools and let it decide when to use them
- Understand how function/tool calling works
Clone the repository:
git clone YOUR_REPOSITORY_URL
cd ghw-agents-geminiInstall dependencies:
npm installCreate your .env file:
cp .env.example .envAdd your Gemini API key:
GEMINI_API_KEY=your_gemini_api_key_hereYou can create an API key using Google AI Studio.
⚠️ Never commit your.envfile or API key to GitHub.
Make your first request to the Gemini API.
node step-1-gemini.jsTurn Gemini into an interactive terminal agent that remembers the current conversation.
node step-2-chat-agent.jsSend an image to Gemini and let the agent understand and reason about what it sees.
Add your image as demo-image.jpg, then run:
node step-3-vision-agent.jsGive Gemini access to a JavaScript weather tool and let the model decide when the tool is needed.
node step-4-tool-agent.jsTry:
What is JavaScript?
Then:
What's the weather in Lagos?
Notice that Gemini can answer the first question directly but decides to use our weather tool for the second.
User
↓
Gemini
↓
Decides a tool is needed
↓
Requests getWeather("Lagos")
↓
Our Node.js app runs the function
↓
Tool result
↓
Gemini
↓
Final answer
Gemini decides which tool to request and what arguments to provide, while our application actually executes the JavaScript function.
Take what we built and make the agent smarter!
Try:
- Adding a calculator tool
- Connecting a real weather API
- Adding another image use case
- Creating multiple tools
- Combining memory + vision + tools
Session: Building Smarter AI Agents with Google Gemini
Check-in: https://events.mlh.com/events/14591-ghw-agents-week-building-smarter-ai-agents-with-google-gemini
Feedback: https://mlh.link/GHWFeedback
Happy building! 🚀