my_agent, is the basis for every lesson that follows.
- Create a clean Python virtual environment (venv).
- Install the ADK CLI package (
google-adk). - Get a Gemini API key from Google AI Studio.
- Keep that key out of source by using an environment variable.
- Scaffold a starter agent with
adk create my_agent. - Run and iterate on
my_agent.
Choose a model and get an API key
ADK is built to work with Gemini models. The fastest way to start is with a free API key from Google AI Studio. Sign in, click “Get API Key,” and copy the key string.
- Recommended model:
gemini-flash-latest— fast and cost-effective for most tasks. - Backend: Google AI Studio — paste your API key when prompted by the ADK CLI.
agent.py or any committed file, it can be accidentally published and abused.
GOOGLE_API_KEY. ADK reads that environment variable automatically when your agent starts.
Never commit API keys or secrets to source control. Use environment variables or a secrets manager instead.
Tip: After exporting
GOOGLE_API_KEY in your shell, ADK will automatically pick it up the next time you run adk run or any other ADK command in that shell session.
- When prompted, choose
gemini-flash-latestas the model. - Choose Google AI Studio for the backend and paste your API key when asked.
adk create my_agent
Run your agent
Now you have a working project folder (
my_agent) with a scaffolded agent.py. Start it and iterate from there; every lesson will add features to this same agent so you build on prior work rather than starting over.
- Open
my_agent/agent.pyand run a simple query. - Add or register tools deliberately, validate inputs, and add robust error handling to avoid crashes like the one above.
- Keep iterating: the agent is code-first, so make small, testable changes and use version control to avoid losing your work.