Install a pinned Google ADK release and run a first agent
Install a pinned ADK version in a virtual environment, keep model credentials out of source and run a small agent with adk run and adk web.
By Invicly Tech, , in Google ADK with Python for AI Agents. About 10 minutes to read.
In short
This path pins google-adk 2.15.1, the stable release current in late 2026, which needs Python 3.11 or newer. You install it in a virtual environment, keep the model key in a .env file that Git ignores, and lay out an agent package that the adk command can find. Then you run it in the terminal with adk run and in the browser with adk web.
Explained simply
ADK, the Agent Development Kit, is Google's open-source framework for building agents. For Python you install a package called google-adk. Because the framework changes quickly, this path pins one exact version, 2.15.1, released in November 2026. Pinning means your code, the docs you read and the examples here all describe the same behaviour.
You install it inside a virtual environment, a private folder of packages for one project. That keeps ADK and its many dependencies away from other projects on your machine. Version 2.15.1 needs Python 3.11 or newer, so check python3 --version first.
The model needs a credential, usually a Gemini API key from Google AI Studio. The key goes in a file named .env next to your agent code. ADK reads that file when it starts. The .env file must never be committed to Git, because anyone with the key can spend your quota.
ADK finds your agent by convention. An agent is a Python package, which is a folder with an __init__.py file, containing agent.py with a variable named root_agent. The adk create command writes this layout for you. Then adk run lets you chat in the terminal and adk web opens a local browser page for chatting and inspecting events.
Press Play on a diagram to walk through it one step at a time.
- 1Create venv
python3 -m venv .venv
- 2Pin ADK
pip install google-adk==2.15.1
- 3Scaffold
adk create support_agent
- 4Add key
.env, ignored by Git
- 5Run
adk run or adk web
- support_agent/
- __init__.py imports agent
- agent.py defines root_agent
- .env holds the key
- .gitignore lists .env
- requirements.txt
- google-adk==2.15.1
- .venv/
- Not committed
- Create in Google AI Studio
- GOOGLE_API_KEY in .env
- Fastest way to start
- Free tier with rate limits
- Needs a Google Cloud project with billing
- GOOGLE_GENAI_USE_ENTERPRISE=1
- Project and location variables
- Uses application default credentials
In depth
Prerequisites and installing a pinned release
You need Python 3.11 or newer, pip, a terminal and Git. A Gemini API key is optional for this module, because the next topic shows a fake model that needs no key. Create a project folder, make a virtual environment and install the exact version. Write the same pin into requirements.txt so teammates and CI get the same release.
After installing, confirm the version with adk --version. If it prints something else, your shell may be using a different Python; activate the environment again. Expected evidence: adk --version prints 2.15.1 and adk --help lists commands such as create, run, web, api_server and eval.
Cleanup is simple: deactivate and delete the .venv folder. Nothing is installed system-wide.
- python3 -m venv .venv, then activate it
- pip install google-adk==2.15.1
- Add google-adk==2.15.1 to requirements.txt
- Database sessions need the extra: google-adk[db]==2.15.1
Keeping credentials out of source
adk create writes a .env file inside the agent folder and also writes a .gitignore that lists .env. Check that line exists before your first commit, and add .env to the repository's top-level .gitignore as well. For a Gemini API key the file needs GOOGLE_API_KEY. For Google Cloud's Gemini Enterprise Agent Platform (formerly Vertex AI) you set GOOGLE_GENAI_USE_ENTERPRISE=1, GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION and sign in with gcloud auth application-default login instead of a key.
Commit a .env.example with placeholder values so others know which variables exist. If a real key ever reaches Git, deleting the file is not enough: revoke or rotate the key, because it stays in history.
- GOOGLE_API_KEY=YOUR_KEY for the Gemini API
- GOOGLE_GENAI_USE_ENTERPRISE=1 for Agent Platform
- Commit .env.example, never .env
- Leaked key: rotate it, then clean history
The agent package layout
adk create support_agent makes a folder with four files: agent.py, __init__.py, .env and .gitignore. __init__.py contains from . import agent, so importing the package loads your agent. agent.py defines root_agent, an Agent with a name, a model, a description and an instruction. The name must be a valid identifier, such as support or ticket_helper.
The parent folder is the agents directory. adk web scans it and lists each package it finds, which is why you run the command from the parent, not from inside the package. Keep tools, fixtures and tests in separate modules next to agent.py so the file stays short.
- You to adk web: adk web in the parent folder1adk web in the parent folder
- adk web to Agent package: Load .env for the agent2Load .env for the agent
- adk web to Agent package: Import package, read root_agent3Import package, read root_agent
- adk web to You: Serve UI on localhost:80004Serve UI on localhost:8000
- You to adk web: Pick the agent, send a message5Pick the agent, send a message
adk run and adk web
adk run support_agent starts a chat loop in the terminal. Useful flags include --in_memory to avoid saving sessions, --jsonl for structured output and --save_session to write the session to a file. adk web starts a local server on 127.0.0.1:8000; pick the agent in the top-left list. By default it stores sessions in a SQLite file under the agent's .adk folder, so conversations survive restarts. Add .adk/ to .gitignore.
Both are development tools. adk web has no login and is for debugging only. For serving real users you will use adk api_server or your own FastAPI app in a later module.
Names that changed from older examples
Many blog posts and samples were written for ADK 1.x. ADK 2.0 reached general availability on 19 May 2026 and moved execution to a graph-based workflow runtime. Watch for these differences. Custom agents that subclass BaseAgent and override _run_async_impl no longer drive execution in 2.x; use callbacks or workflows instead. Events gained node_info and output fields, which matters if you stored events in fixed database columns. Docs and the adk create template now use GOOGLE_GENAI_USE_ENTERPRISE, while older samples use GOOGLE_GENAI_USE_VERTEXAI; the client still reads the old name, but the new one wins if both are set. The docs moved to adk.dev from the older google.github.io address.
- ADK 2.0 GA: 19 May 2026
- BaseAgent._run_async_impl overrides are ignored in 2.x
- Events have node_info and output
- Stay on 1.x only if you must: google-adk~=1.0
Learn it in 5 short steps
About 30m each. Track them with a timer in your plan.
- 1Pin google-adk in a virtual environment~30m
- 2Load credentials from a .env outside Git~30m
- 3Lay out the agent package~30m
- 4Run the agent with adk run and adk web~30m
- 5Note names that changed from older examples~30m
Key points
- Pin an exact version so examples, docs and tests all match the same API.
- ADK looks for a variable named root_agent in the agent package; adk create writes it for you.
- Run adk run and adk web from the parent folder that contains the agent package.
- adk web is a development tool only; never expose it as a production service.
- Newer ADK writes GOOGLE_GENAI_USE_ENTERPRISE where older examples used GOOGLE_GENAI_USE_VERTEXAI.
Key terms
Tap a card to flip it. 0/5 known
Examples
python3 -m venv .venv && source .venv/bin/activate
pip install google-adk==2.15.1
adk create support_agent # writes .env, .gitignore, __init__.py, agent.py
# edit support_agent/.env: GOOGLE_API_KEY=<your-key>
adk run support_agent # chat in the terminal
adk web --port 8000 # then open http://localhost:8000Run the adk commands from the folder that contains support_agent/.
Scaffolding and running the support agent
Step 1: create and activate a virtual environment. Step 2: install the pinned release. Step 3: run adk create and answer the prompts, or pass --model and --api_key. Step 4: open agent.py and set a clear instruction. Step 5: run adk run support_agent and ask a question. Expected evidence: the terminal shows your message and the agent's reply. Cleanup: press Ctrl+C, then delete the .adk folder if you want to discard saved sessions.
mkdir adk-support && cd adk-support
python3 -m venv .venv && source .venv/bin/activate
pip install google-adk==2.15.1
adk --version # 2.15.1
adk create support_agent
ls -a support_agent # .env .gitignore __init__.py agent.py
adk run support_agentThe minimal agent.py
This file is all ADK needs. The model string uses the alias from the ADK docs; replace it with the model your account offers. The instruction says what the agent is for and what to do when it does not know, which matters more than any other setting at this stage.
from google.adk.agents import Agent
root_agent = Agent(
name="support",
model="gemini-flash-latest",
description="Answers questions about the Contoso Notes app.",
instruction=(
"You answer questions about Contoso Notes. "
"If you do not know, say so and suggest contacting support."
),
)Quick reference
- pip install google-adk==2.15.1 (needs Python 3.11+)
- adk create NAME writes agent.py, __init__.py, .env and .gitignore
- agent.py must define root_agent
- adk run NAME from the parent folder; adk web --port 8000 for the browser UI
- GOOGLE_API_KEY in .env; never commit .env
- Agent Platform: GOOGLE_GENAI_USE_ENTERPRISE=1, GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION
- adk web keeps sessions in the agent folder under .adk/session.db; add .adk/ to .gitignore
Common mistakes
- Running adk web from inside the agent folder, so the UI lists no agents.
- Committing .env with a real key; rotate the key at once if that happens.
- Copying ADK 1.x examples that subclass BaseAgent and override _run_async_impl, which 2.x silently ignores.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Create a virtual environment, install google-adk 2.15.1 and confirm the version and available commands.
- Exercise 2medium
Scaffold support_agent, prove that .env is ignored by Git, and add a .env.example with placeholders.
- Exercise 3hard
Run the agent in both adk run and adk web, then find where adk web saved the session and delete it to reset.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Do I need a paid Google Cloud account?
- No. A Gemini API key from Google AI Studio has a free tier, and the next topic shows a fake model that needs no key at all.
- Why pin 2.15.1 instead of installing the latest?
- ADK releases often, and minor versions sometimes change behaviour. Pinning keeps your code matching the docs you read until you choose to upgrade.
- Can I use adk web in production?
- No. It is a development and debugging tool with no authentication. Serve real users through adk api_server or your own API layer.