This project creates an AI agent from scratch using Node.js and Google's Gemini API, based on the open-source tutorial from Hendrixer/agent-from-scratch. It replaces OpenAI with Google Gemini, making it completely free to experiment with.
✅ Perfect for developers looking to explore AI agents without incurring any costs.
- Uses Google Gemini API (
@google/genai) - No OpenAI key needed – works entirely on Gemini’s free tier
- Built in TypeScript for type safety and modular design
- Based on a proven educational template
- Fully extensible: add tools, memory, workflows, and more
- Node.js v18+
- A free Google Gemini API key from AI Studio
👉 Get your Gemini API key here: Google AI Studio API Key
- Clone the repository
git clone https://github.com/gsk-007/ai-agent-gemini.git
cd ai-agent-gemini- Install dependencies
npm install
# or
bun install- Add your environment variables
Create a .env file in the root directory with the following content:
GEMINI_API_KEY=your_google_api_key_here🔐 Keep your API key secret! Never commit it to version control.
- Chat With Model
npm run dev "<your message>"
# or
bun run index.ts "<your message>"├── src/
│ ├── agent.ts # Core agent logic using Gemini
│ ├── tools.ts # Extendable tool interface
│ ├── memory.ts # Optional memory implementation
│ └── types.ts # Shared types and interfaces
├── index.ts # Entry point
├── .env # Environment variables (not committed)
├── package.json
└── README.md
Here’s what you get for free:
- 15 requests/minute
- 1,500 requests/day
- 1 million tokens/minute
- Cost: Free
- 2 requests/minute
- 50 requests/day
- 32k tokens/minute
- Cost: Free
⚠️ Limits are generous for prototyping but can be raised with billing enabled.
More info: https://ai.google.dev/pricing
MIT – Use it, modify it, build your own agent!
PRs welcome! Feel free to fork the project, add your own tools, or extend the agent's reasoning abilities.