Building and Deploying AI Agents in Minutes with Google’s ADK — Part 1
Introduction to ADK
The Agent Development Kit (ADK) is Google’s open-source framework designed to simplify the development, deployment, and management of AI agent applications. ADK provides a complete toolkit for building, testing, and deploying multi-agent applications with minimal code.
Getting Started with ADK
Installation
pip install google-adkCreating a Simple Agent
ADK uses a convention-based approach that dramatically simplifies agent creation. Here’s all you need for a basic weather agent:
- Create your agent directory structure:
weather_agent/
├── __init__.py
├── agent.py
└── .env- In
__init__.py, simply import your agent module:
from . import agent- In
agent.py, define your agent and tools:
from google.adk.agents import Agent
def get_weather(location: str) -> str:
"""Get the weather for a specific location"""
return f"The weather in {location} is sunny with a temperature of 70 degrees."
# Root agent is automatically detected by ADK CLI
root_agent = Agent(
name="weather_agent",
description="You are a weather agent that can get the weather for a specific location.",
tools=[get_weather],
model="gemini-2.0-flash-exp",
)In .env, configure your API access:
GOOGLE_GENAI_USE_VERTEXAI="False"
GOOGLE_API_KEY="your_api_key_here"Running Your Agent
With ADK CLI, running your agent is as simple as:
# Run in interactive CLI mode
adk run weather_agent# Run with web UI
adk web weather_agentExample Interaction
When you run the agent in CLI mode, you’ll see an interaction like this:
Running agent weather_agent, type exit to exit.
user: What's the weather in New York?
[weather_agent]: The weather in New York is sunny with a temperature of 70 degrees.user: How about in Tokyo?
[weather_agent]: The weather in Tokyo is sunny with a temperature of 70 degrees.user: exit
The web UI provides a similar chat experience through a browser interface at http://localhost:8000:
Key Concepts
Agents
Agents are the core building blocks in ADK:
- Define capabilities and behavior
- Connect to foundation models (like Gemini)
- Expose tools for performing actions
Tools
Functions that agents can call:
def search_database(query: str) -> list:
"""Search the database for information"""
# Database logic here
return resultsAdvanced Tools
ADK supports rich parameter types using Pydantic:
from pydantic import BaseModel, Field
class CustomerInfo(BaseModel):
name: str = Field(description="Customer's full name")
email: str = Field(description="Customer's email address")
def register_customer(customer: CustomerInfo) -> str:
return f"Customer {customer.name} registered successfully"Building Multi-Agent Systems
ADK excels at creating systems of specialized agents:
# In research_agent/agent.py
root_agent = Agent(
name="research_agent",
description="Finds relevant information from sources",
tools=[search_web],
model="gemini-2.0-pro",
)
# In writing_agent/agent.py
root_agent = Agent(
name="writing_agent",
description="Creates well-written content",
tools=[format_text],
model="gemini-2.0-pro",
)Deploying to Google Cloud Run
# Authenticate with Google Cloud
gcloud auth login
# Deploy with web UI
adk deploy cloud_run --with_ui weather_agent
# Make service public
gcloud run services add-iam-policy-binding SERVICE_NAME \
--region=REGION --member="allUsers" --role="roles/run.invoker"ADK handles all the complex deployment tasks:
- Generating deployment files
- Building and pushing Docker containers
- Setting up Cloud Run services
- Providing a URL for accessing your agent
Deployment Output Example
Building using Dockerfile and deploying container to Cloud Run service [adk-default-service-name]...
...
✓ Deployed to https://adk-default-service-name-abc123456.region.run.app
This service is not public. To make it public, run:
gcloud run services add-iam-policy-binding adk-default-service-name --region=region --member="allUsers" --role="roles/run.invoker"The agent is now deployed and accessible at: https://adk-default-service-name-abc123456.region.run.app
Your agent is now available on the web and can be integrated with other applications via API calls.
Coming Next
In Part 2 of this tutorial series, we’ll explore how ADK integrates with the MCP (Model Context Protocol)
Part 3 will focus on Agent-to-Agent (A2A) communication, allowing your ADK agents to collaborate with agents from other systems through the open A2A protocol.
Resources:
