Google Agent Development Kit (ADK)

1.28.1 · active · verified Thu Apr 09

The Google Agent Development Kit (ADK) is an open-source, code-first Python framework for building, evaluating, and deploying sophisticated AI agents. It provides a flexible and modular approach to developing multi-agent systems, optimized for Gemini and the Google ecosystem but designed to be model-agnostic. Currently at version 1.28.1, ADK features a rich tool ecosystem, robust debugging capabilities, and support for orchestrating complex agent workflows. It maintains an active release cadence with frequent updates and new features.

Warnings

Install

Imports

Quickstart

This quickstart defines a simple conversational AI agent using the `Agent` class. It demonstrates how to set up the agent with a name, model, description, and instruction. The `root_agent` variable name is crucial for ADK to discover and run the agent. Users need to provide a Google API key (via `GOOGLE_API_KEY` environment variable) or configure Vertex AI access. The code includes a warning for missing authentication setup. Once saved in a proper project structure (e.g., `my_agent/agent.py` and `my_agent/__init__.py`), it can be run via the `adk CLI`.

import os
from google.adk.agents import Agent

# Ensure you have your Google AI Studio API key set as an environment variable
# For example: export GOOGLE_API_KEY='YOUR_API_KEY'
# If using Vertex AI, set GOOGLE_GENAI_USE_VERTEXAI='True'
if not os.environ.get('GOOGLE_API_KEY') and not os.environ.get('GOOGLE_GENAI_USE_VERTEXAI'):
    print("Warning: GOOGLE_API_KEY or GOOGLE_GENAI_USE_VERTEXAI environment variable not set.")
    print("Please set one to run the agent. You can get a free API key at aistudio.google.com/api")
    exit()

# Define your agent - the main agent MUST be named 'root_agent'
root_agent = Agent(
    name="hello_assistant",
    model="gemini-2.0-flash", # Or your preferred model, e.g., 'gemini-1.5-pro'
    description="A friendly AI assistant for general conversation",
    instruction=(
        "You are a warm and helpful assistant. "
        "Greet users enthusiastically and answer their questions clearly. "
        "Be conversational and friendly!"
    ),
)

# To run this agent, save it as `agent.py` in a directory (e.g., `my_agent/`)
# and ensure an empty `__init__.py` exists in the same directory (`my_agent/__init__.py`).
# Then, from the parent directory, run:
# adk run my_agent
# Or for the web UI:
# adk web --agent-dir my_agent

view raw JSON →