1. Getting Started

This blog is part of the ADK Masterclass - Hands-On Series. We'll explore the fundamentals of Google's Agent Development Kit (ADK) and build our first AI agent.

View Code on GitHub

Table of Contents

What is ADK?

The Agent Development Kit (ADK) is an open-source, flexible, and modular framework designed for creating and deploying AI agents. ADK aims to simplify the process for developers to build, deploy, and manage agent architectures, whether for simple tasks or complex workflows, using either coding or a visual interface.
  • Model-agnostic: Can plug in any model like OpenAI, Ollama, Llama 3, etc. ADK supports all major LLM providers, making it versatile for different use cases.
  • Deployment-agnostic: ADK can be deployed on any infrastructure, from local development to production, on our laptop, in a Docker container, on Cloud Run, on Vertex AI Agent Engine, GKE, or on any custom infrastructure.
  • Compatible with other frameworks: Can work together with other libraries and tools, such as LangChain, CrewAI, OpenAI function calling, FastAPI, or any Python ecosystem.

Key Features

  • Flexible Orchestration: Build workflows using Sequential, Parallel, or Loop steps, or let the LLM choose what to do next.
  • Multi-Agent Architecture: Combine multiple specialized agents to create a modular, scalable system.
  • Rich Tool Ecosystem: Add built-in tools, custom functions, third-party libraries, or even other agents as tools.
  • Deployment Ready: Run agents locally, in containers, on Vertex AI Agent Engine, or any custom environment.
  • Built-in Evaluation: Evaluate both the final output and each step to understand and improve agent performance.

Prerequisites

Before getting started, make sure we have:

  • Python 3.11 or higher installed
  • ADK version 1.18.0 or higher (required for Visual Agent Builder features)
  • Google Cloud project

Setting Up Our Environment

1. Get API Keys

To use ADK with Google's AI models, we'll need an API key. Get one from Google AI Studio:

  1. Visit https://aistudio.google.com/api-keys
  2. Sign in with your Google account
  3. Click "Create API Key"
  4. Copy the generated API key

Set the API key as an environment variable:

export GOOGLE_API_KEY="our-api-key-here"

2. Set Up Our Project

Create a virtual environment:

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

3. Installation

Install ADK using pip:

pip install google-adk

Verify the installation by checking the version:

❯ adk --version
adk, version 1.18.0

We can also view all available commands:

❯ adk --help

Usage: adk [OPTIONS] COMMAND [ARGS]...

  Agent Development Kit CLI tools.

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  api_server   Starts a FastAPI server for agents.
  conformance  Conformance testing tools for ADK.
  create       Creates a new app in the current folder with prepopulated agent template.
  deploy       Deploys agent to hosted environments.
  eval         Evaluates an agent given the eval sets.
  eval_set     Manage Eval Sets.
  run          Runs an interactive CLI for a certain agent.
  web          Starts a FastAPI server with Web UI for agents.

4. Building Our First Agent

Let's create our first agent using the ADK CLI. Run the following command:

adk create simple_agent

The CLI will guide us through the setup process. We'll be prompted to:

  1. Choose a model for the root agent:
    • 1. gemini-2.5-flash
    • 2. Other models (fill later)
    Select option 1 for gemini-2.5-flash.
  2. Choose a backend:
    • 1. Google AI
    • 2. Vertex AI
    Select option 1 for Google AI.
  3. Enter Google API key: If we don't have an API key, we can create one at https://aistudio.google.com/apikey. Enter our API key when prompted.

Here's what the interactive session looks like:

❯ adk create simple_agent

Choose a model for the root agent:

1. gemini-2.5-flash

2. Other models (fill later)

Choose model (1, 2): 1

1. Google AI

2. Vertex AI

Choose a backend (1, 2): 1

Don't have API Key? Create one in AI Studio: https://aistudio.google.com/apikey

Enter Google API key [YOUR_API_KEY]:

Agent created in /Users/arjunprabhulal/google-adk-masterclass/1-adk-getting-started/simple_agent:

- .env
- __init__.py
- agent.py

Our agent project has been created with the following structure:

└── simple_agent
    ├── __init__.py
    ├── .env
    └── agent.py

2 directories, 3 files

The .env file contains our configuration:

cat simple_agent/.env

GOOGLE_GENAI_USE_VERTEXAI=0
GOOGLE_API_KEY=YOUR_API_KEY

The agent.py file contains our agent definition:

from google.adk.agents import Agent

root_agent = Agent(
    model='gemini-2.5-flash',
    name='root_agent',
    description='A helpful assistant for user questions.',
    instruction='Answer user questions to the best of your knowledge',
)

Next Steps

Now that we've created our first agent, we're ready to dive into more topics:

Resources

Comments