Vertex AI express mode¶
Google Cloud Vertex AI express mode provides a no-cost access tier for prototyping and development, allowing you to use Vertex AI services without creating a full Google Cloud Project. This service includes access to many powerful Vertex AI services, including:
You can sign up for an express mode account using a Gmail account and receive an API key to use with the ADK. Obtain an API key through the Google Cloud Console. For more information, see Vertex AI express mode.
Preview release
The Vertex AI express mode feature is a Preview release. For more information, see the launch stage descriptions.
Vertex AI express mode limitations
Vertex AI express mode projects are only valid for 90 days and only select services are available to be used with limited quota. For example, the number of Agent Engines is restricted to 10 and deployment to Agent Engine requires paid access. To remove the quota restrictions and use all of Vertex AI's services, add a billing account to your express mode project.
Configure Agent Engine container¶
When using Vertex AI express mode, create an AgentEngine object to enable
Vertex AI management of agent components such as Session and Memory objects.
With this approach, Session objects are handled as children of the
AgentEngine object. Before running your agent make sure your environment
variables are set correctly, as shown below:
Next, create your Agent Engine instance using the Vertex AI SDK.
-
Import Vertex AI SDK.
-
Initialize the Vertex AI Client with your API key and create an agent engine instance.
-
Get the Agent Engine name and ID from the response to use with Memories and Sessions.
Manage Sessions with VertexAiSessionService¶
VertexAiSessionService
is compatible with Vertex AI express mode API Keys. You can instead initialize
the session object without any project or location.
# Requires: pip install google-adk[vertexai]
# Plus environment variable setup:
# GOOGLE_GENAI_USE_VERTEXAI=TRUE
# GOOGLE_API_KEY=PASTE_YOUR_ACTUAL_EXPRESS_MODE_API_KEY_HERE
from google.adk.sessions import VertexAiSessionService
# The app_name used with this service should be the Reasoning Engine ID or name
APP_ID = "your-reasoning-engine-id"
# Project and location are not required when initializing with Vertex express mode
session_service = VertexAiSessionService(agent_engine_id=APP_ID)
# Use REASONING_ENGINE_APP_ID when calling service methods, e.g.:
# session = await session_service.create_session(app_name=APP_ID, user_id= ...)
Session Service Quotas
For Free express mode Projects, VertexAiSessionService has the following quota:
- 10 Create, delete, or update Vertex AI Agent Engine sessions per minute
- 30 Append event to Vertex AI Agent Engine sessions per minute
Manage Memory with VertexAiMemoryBankService¶
VertexAiMemoryBankService
is compatible with Vertex AI express mode API Keys. You can instead initialize
the memory object without any project or location.
# Requires: pip install google-adk[vertexai]
# Plus environment variable setup:
# GOOGLE_GENAI_USE_VERTEXAI=TRUE
# GOOGLE_API_KEY=PASTE_YOUR_ACTUAL_EXPRESS_MODE_API_KEY_HERE
from google.adk.memory import VertexAiMemoryBankService
# The app_name used with this service should be the Reasoning Engine ID or name
APP_ID = "your-reasoning-engine-id"
# Project and location are not required when initializing with express mode
memory_service = VertexAiMemoryBankService(agent_engine_id=APP_ID)
# Generate a memory from that session so the Agent can remember relevant details about the user
# memory = await memory_service.add_session_to_memory(session)
Memory Service Quotas
For Free express mode Projects, VertexAiMemoryBankService has the following quota:
- 10 Create, delete, or update Vertex AI Agent Engine memory resources per minute
- 10 Get, list, or retrieve from Vertex AI Agent Engine Memory Bank per minute
Code Sample: Weather Agent with Session and Memory¶
This code sample shows a weather agent that utilizes both
VertexAiSessionService and VertexAiMemoryBankService for context management,
allowing your agent to recall user preferences and conversations.
- Weather Agent with Session and Memory using Vertex AI express mode