DEV Community

Koichi
Koichi

Posted on

How to Run Gemini 3 on Agent Engine with ADK

If you're trying to deploy an ADK agent with Gemini 3 to Agent Engine and getting a 404 error, here's the fix.

TL;DR

Two ways to make it work:

1. adk deploy agent_engine command

Pass a .env file containing GOOGLE_CLOUD_LOCATION=global via the --env_file flag.

uv run adk deploy agent_engine \
        --project=$PROJECT_ID \
        --region=$LOCATION_ID \
        --env_file=$ENV_FILE \
        --display_name="Greeting Agent" \
        sample_agent
Enter fullscreen mode Exit fullscreen mode

2. Python script

Add the following to the agent_engines.create parameters:

remote_agent = agent_engines.create(
    agent_engine=root_agent,
    display_name="Greeting Agent",
    requirements=[...],
    env_vars={
        "GOOGLE_CLOUD_LOCATION": "global",  # ← set the global region
    },
)
Enter fullscreen mode Exit fullscreen mode

Sample code

GitHub logo Koichi73 / adk-gemini-3-in-agent-engine

How to run ADK agents, including Gemini 3, on Agent Engine.

Run Gemini 3 Series on ADK + Agent Engine

A sample project for deploying ADK agents with Gemini 3 series models (e.g., gemini-3-flash-preview) to Agent Engine.

To use Gemini 3 series on Agent Engine, you need to pass the environment variable GOOGLE_CLOUD_LOCATION=global. This repository demonstrates two ways to do that.

Prerequisites

  • Python 3.11+
  • uv
  • Google Cloud project with Vertex AI API enabled
  • GCS bucket for staging

Setup

cp .env.example .env
# Edit .env and set GOOGLE_CLOUD_PROJECT, BUCKET_NAME
Enter fullscreen mode Exit fullscreen mode
uv sync
Enter fullscreen mode Exit fullscreen mode

Deployment

Option 1: Shell script (adk deploy CLI)

Pass the path to a .env file containing GOOGLE_CLOUD_LOCATION=global via the --env_file option of adk deploy agent_engine.

bash deploy.sh
Enter fullscreen mode Exit fullscreen mode
# Relevant part of deploy.sh
uv run adk deploy agent_engine \
        --project=$PROJECT_ID \
        --region=$LOCATION_ID \
        --env_file=$ENV_FILE \    # ← path to .env file containing GOOGLE_CLOUD_LOCATION=global
        --display_name="Greeting Agent" \
        sample_agent
Enter fullscreen mode Exit fullscreen mode

Option 2: Python script

Pass…




Why does this happen?

  • Gemini 3 models (as of March 2026) are only available in the global region
  • Agent Engine deployments don't let you specify global as the region directly
  • Without this workaround, ADK agents deployed to Agent Engine will hit a 404 error — the model can't be found

Result

Agent definition:

from google.adk.agents.llm_agent import Agent

MODEL = "gemini-3-flash-preview"

root_agent = Agent(
    model=MODEL,
    name='root_agent',
    description="greeting",
    instruction="Please greet me cheerfully.",
)
Enter fullscreen mode Exit fullscreen mode

Agent Engine playground:

Agent Engine playground

That's it — hope this saves you some debugging time!

Top comments (0)