Summary
When deploying an ADK application to Cloud Run (or any environment where a deprecated Gemini model alias is configured), all LlmAgent calls silently fail with a confusing 404 NOT_FOUND error that does not clearly indicate the root cause.
Environment
google-adk: 2.1.0
google-genai: latest
- Platform: Google Cloud Run (asia-northeast1)
- Python: 3.12
Steps to Reproduce
- Set
GEMINI_MODEL=gemini-flash-latest in the environment (common in older ADK projects or tutorials that referenced this alias)
- Pass it to
LlmAgent:
MODEL = os.environ.get("GEMINI_MODEL", "gemini-flash-latest")
agent = LlmAgent(name="MyAgent", model=MODEL, ...)
- Deploy to Cloud Run and invoke the agent
Actual Error
google.genai.errors.ClientError: 404 NOT_FOUND.
{'error': {'code': 404, 'message': 'This model models/gemini-2.0-flash is
no longer available. Please update your code to use a newer model for the
latest features and improvements.', 'status': 'NOT_FOUND'}}
Problem
The error message mentions models/gemini-2.0-flash — the resolved underlying model ID — but the user configured gemini-flash-latest. This disconnect makes diagnosis difficult:
- The user sees
gemini-2.0-flash in the error but never wrote that name anywhere
- There is no hint that
gemini-flash-latest is the problematic alias
- The error surface is deep in the agent invocation chain, far from the configuration
This was particularly confusing during a hackathon where the app appeared to work locally (older cached responses / different routing) but failed 100% on Cloud Run.
Root Cause
gemini-flash-latest is a non-versioned alias that previously resolved to gemini-2.0-flash. Google has since deprecated gemini-2.0-flash (the specific model behind the alias), causing the alias to produce 404 errors.
Note: ADK 2.1.0 correctly uses DEFAULT_MODEL = 'gemini-2.5-flash' — the issue occurs when users explicitly pass an old alias via environment variable or hardcoded string.
Suggested Improvements
Option A — Startup validation warning
Before agent invocation, validate the model string against a known deprecated-alias list and emit a logging.warning:
DeprecationWarning: model alias 'gemini-flash-latest' is no longer available.
Please use 'gemini-2.5-flash' or a versioned model ID.
Option B — Improved error interception
Catch 404 NOT_FOUND errors from the Gemini API and re-raise with a user-friendly message:
ModelDeprecatedError: The model alias 'gemini-flash-latest' resolved to
'gemini-2.0-flash' which has been deprecated. Please update your model
configuration to 'gemini-2.5-flash'.
Option C — Documentation
Add a "Model Version Management" section to the ADK docs / README warning users against non-versioned aliases and recommending pinned model IDs.
Workaround
Replace any occurrence of gemini-flash-latest (or other non-versioned aliases) with a specific versioned model ID:
# Before (breaks silently when alias is deprecated)
MODEL = os.environ.get("GEMINI_MODEL", "gemini-flash-latest")
# After (stable, explicit)
MODEL = os.environ.get("GEMINI_MODEL", "gemini-2.5-flash")
This was discovered while building a multi-agent privacy tool (AI Shield Persona Agent) for the ADK Hackathon. Sharing in case it helps other hackathon participants and ADK users.
Summary
When deploying an ADK application to Cloud Run (or any environment where a deprecated Gemini model alias is configured), all
LlmAgentcalls silently fail with a confusing404 NOT_FOUNDerror that does not clearly indicate the root cause.Environment
google-adk: 2.1.0google-genai: latestSteps to Reproduce
GEMINI_MODEL=gemini-flash-latestin the environment (common in older ADK projects or tutorials that referenced this alias)LlmAgent:Actual Error
Problem
The error message mentions
models/gemini-2.0-flash— the resolved underlying model ID — but the user configuredgemini-flash-latest. This disconnect makes diagnosis difficult:gemini-2.0-flashin the error but never wrote that name anywheregemini-flash-latestis the problematic aliasThis was particularly confusing during a hackathon where the app appeared to work locally (older cached responses / different routing) but failed 100% on Cloud Run.
Root Cause
gemini-flash-latestis a non-versioned alias that previously resolved togemini-2.0-flash. Google has since deprecatedgemini-2.0-flash(the specific model behind the alias), causing the alias to produce404errors.Note: ADK
2.1.0correctly usesDEFAULT_MODEL = 'gemini-2.5-flash'— the issue occurs when users explicitly pass an old alias via environment variable or hardcoded string.Suggested Improvements
Option A — Startup validation warning
Before agent invocation, validate the
modelstring against a known deprecated-alias list and emit alogging.warning:Option B — Improved error interception
Catch
404 NOT_FOUNDerrors from the Gemini API and re-raise with a user-friendly message:Option C — Documentation
Add a "Model Version Management" section to the ADK docs / README warning users against non-versioned aliases and recommending pinned model IDs.
Workaround
Replace any occurrence of
gemini-flash-latest(or other non-versioned aliases) with a specific versioned model ID:This was discovered while building a multi-agent privacy tool (AI Shield Persona Agent) for the ADK Hackathon. Sharing in case it helps other hackathon participants and ADK users.