Deploy your first agent to Vertex AI Agent Engine
Source notebook
Repo path:
agents/agent_engine/tutorial_deploy_your_first_adk_agent_on_agent_engine.ipynb· Open on GitHub · intermediate
Deploys ADK agents to Vertex AI Agent Engine with Express Mode, agent object, and inline source workflows.
Summary
This notebook teaches how to deploy an Agent Development Kit agent with Google Search capability to Vertex AI Agent Engine. It starts with Express Mode using an API key and the ADK CLI, then shows production-oriented deployments from an in-memory AdkApp and from local inline source files. It demonstrates creating or downloading an agent, deploying it, streaming queries, managing sessions, and deleting deployed agents.
Key code patterns
Express Mode ADK CLI deploy
api_key = getpass("Enter your Generative Language API Key: ")
!adk create my_agent --api_key={api_key}
!adk deploy agent_engine my_agentShows the fastest path for deploying a new ADK agent with an API key.
Get deployed agent
import vertexai
client = vertexai.Client(api_key=api_key)
agent_resource_name = "projects/.../locations/us-central1/reasoningEngines/..."
express_agent = client.agent_engines.get(name=agent_resource_name)Connects to an Agent Engine resource returned by deployment.
Create Google Search ADK agent
from google.adk.agents import LlmAgent
from google.adk.tools import google_search
local_agent = LlmAgent(
name="search_agent",
model="gemini-2.5-flash",
tools=[google_search],
)Defines an ADK LLM agent with Google Search as a tool.
Wrap agent in AdkApp
from vertexai import agent_engines
adk_app = agent_engines.AdkApp(
agent=local_agent,
enable_tracing=True,
)Provides the Agent Engine interface, session management, and tracing.
Deploy AdkApp
remote_app = client.agent_engines.create(
agent=adk_app,
config={
"requirements": ["google-cloud-aiplatform[adk,agent_engines]"],
"staging_bucket": STAGING_BUCKET,
},
)Packages and deploys an in-memory ADK app through the Vertex AI SDK.
Stream query with session
remote_session = await remote_app.async_create_session(user_id="demo_user_adk")
async for event in remote_app.async_stream_query(
user_id="demo_user_adk",
session_id=remote_session["id"],
message="What are the top tech trends in 2025?",
):
print(event)Uses persistent conversation state while streaming agent responses.
Inline source deployment
inline_agent = client.agent_engines.create(
config={
"source_packages": ["academic_research", "deployment", "requirements.txt"],
"entrypoint_module": "deployment.deploy",
"entrypoint_object": "adk_app",
"class_methods": class_methods,
},
)Deploys file-based source for automated and reproducible workflows.
Models & APIs used
- Models: gemini-2.5-flash
- APIs / services: Vertex AI, Vertex AI Agent Engine, Generative Language API, Cloud Storage
- SDKs / libraries:
google-adk,google-cloud-aiplatform,vertexai
When to use this
Use this pattern when deploying ADK agents with web search to managed Vertex AI Agent Engine for prototypes or production workflows.
Gotchas & caveats
- Express Mode uses an API key and requires keeping the Generative Language API key private.
- Agent object deployment requires a Google Cloud project with billing enabled, Vertex AI API enabled, IAM permissions, and a Cloud Storage staging bucket.
- Inline Source deployment requires a Google Cloud project with billing enabled, Vertex AI API enabled, and IAM permissions.
- The notebook uses us-central1 in resource names and configuration examples.
- Deployments are described as taking 5-10 minutes.
- The notebook installs packages from GitHub branches, including google-adk and google-cloud-aiplatform builds.
- Deployed agents should be deleted after experimentation to avoid unexpected charges.
Best practices
- Start with Express Mode if new to Vertex AI Agent Engine.
- Do not share or commit API keys publicly.
- Use agent object deployment for interactive development in notebook environments like Colab.
- Wrap ADK agents in AdkApp before deploying to Agent Engine.
- Enable tracing on AdkApp for debugging.
- Use Inline Source deployment for CI/CD pipelines, version control, reproducible builds, and infrastructure as code.
- Create sessions when querying deployed agents that need conversation history and state.
- Clean up deployed agents when finished.
Related
- Concepts: Agents & ADK · Agent Engine · Function Calling & Tools
- Entities: Vertex AI · Agent Development Kit · Cloud Storage · Function Calling · Gemini
- Area: Agents & ADK Notebooks
- Best practices: Agents & ADK - Best Practices · Agent Engine - Best Practices · Function Calling & Tools - Best Practices