Build Your First AI Agent on Mac (Safe Setup)
1. Create your project folder(Do this in Terminal)
This creates a new folder where your AI project will live.
mkdir ai-agent
2. Move into your project folder(Terminal)
This enters your new project directory.
cd ai-agent
Think of this as entering your workshop.
3. Create a virtual environment(Terminal)
This creates an isolated Python environment for your project.
It keeps your Mac’s main Python safe.
python3 -m venv venv
It creates a folder called venv.
4. Activate the virtual environment(Terminal)
This tells your Mac:
Use this project’s Python, not the system Python.
source venv/bin/activate
After this you should see:
(venv) kiamalek@Kias-MacBook-Pro ai-agent %
That means you are safely inside your isolated environment.
5. Install Google ADK(Terminal)
This installs Google’s Agent Development Kit.
It is the toolkit used to build AI agents.
pip install google-adk
This installs everything only inside venv.
6. Create your Python file(Terminal)
This creates your agent file.
touch agent.py
This file will contain your agent’s brain.
7. Open the project in Cursor / VS Code
Open the whole ai-agent folder.
Inside it, open:
agent.py
Then paste:
from google.adk.agents import Agent
root_agent = Agent(
name="hello_agent",
model="gemini-2.0-flash",
instruction="You are a helpful AI assistant."
)
What this means:
name= your agent’s identitymodel= which Gemini model it usesinstruction= how it behaves
Save with:
Cmd + S
8. Add your Google API key(Back in Terminal)
This connects your agent to Google’s AI model.
Without this, it cannot generate responses.
export GOOGLE_API_KEY="your_key_here"
Replace:
your_key_here
with your real key.
Important:
This only works for the current terminal session.
9. Start your AI agent(Terminal)
Run:
adk web
This launches your local AI web app.
It starts a local server on your Mac.
10. Open your agent in browser
Go to:
http://localhost:8000
Now your AI agent is live.
You can talk to it like a chatbot.
What you built
You now have:
✅ Your own AI agent
✅ Running locally on your Mac
✅ Using Google Gemini
✅ Safe inside an isolated environment
✅ Ready for expansion (tools, memory, APIs, workflows)
Think of it like:
Folder = workshop
venv = protected lab
agent.py = brain
API key = power source
adk web = engine start
localhost = control panel
Important:
🚫 Never share your API key
🚫 Never use --break-system-packages
🚫 Never use sudo pip install