Reported: identical code and the same API key on two laptops, one said
"connected", the other said "Gemini (Google) model does not exist or is
not available." Traced to the connectivity probe hardcoding a single
model, gemini-3.6-flash — the newest entry in GEMINI_MODELS. Vertex AI
Model Garden availability is scoped per Google Cloud project and region,
so a brand-new model can reach one project's console before another; the
key, billing and every older model can be completely fine on the "failing"
laptop and this probe would still report the connection as broken.
Root env-var mechanism is separate and expected: GOOGLE_GENAI_USE_VERTEXAI
/ GOOGLE_CLOUD_PROJECT / GOOGLE_CLOUD_LOCATION live in envs.json, which is
machine-local and does not travel with `git pull` — each laptop configures
its own. That part is not a bug. The bug is that whichever laptop's project
had not yet had gemini-3.6-flash enabled got a false "everything is
broken" instead of "your key works, one specific model isn't rolled out
here yet."
Fix: try every model in the registry (oldest to newest, skipping the
tool-calling "-customtools" variant) and succeed on the first one that
works. A 404 on one model moves to the next; any other error (auth,
permission, quota, billing) stops immediately and is reported as-is,
since that applies no matter which model is asked for.
Also fixes a regression introduced while writing this: client construction
moved outside the per-model try/except, so bad service-account JSON or a
missing google-genai install would have escaped as an unhandled exception
instead of the graceful {"success": False, ...} every other path returns.
Caught by test_client_construction_failure_is_reported_gracefully before
it shipped.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>