#Heads up Google devs β€” 4 gotchas building a Gemini + Sheets Cloud Function agent (Python)

1 messages Β· Page 1 of 1 (latest)

floral oyster
#

🚨 Heads up Google devs β€” 4 gotchas building a Gemini + Sheets Cloud Function agent (Python)

─────────────────────────────────────
1️⃣ google-generativeai is dead
Symptom: 404 on gemini-1.5-pro, FutureWarning on import
Cause: SDK EOL, v1beta endpoint dropped the model
Fix: pip install google-genai>=1.0.0, swap to Client() API
model = "gemini-2.0-flash"

─────────────────────────────────────
2️⃣ AI Studio API keys β‰  GCP project keys
Symptom: 429 RESOURCE_EXHAUSTED, limit: 0 β€” even with billing + $300 credits
Cause: Studio keys live in Google's shared project, NOT yours. Your GCP billing doesn't cover them.
Fix: Create the key at console.cloud.google.com/apis/credentials inside your project, not aistudio.google.com

─────────────────────────────────────
3️⃣ Sheets API rejects unquoted tab names with spaces
Symptom: 400 "Unable to parse range: Raw Data!C2:C"
Cause: Tab names containing spaces must be wrapped in single quotes in range strings
Fix: RAW_TAB = "'Raw Data'" (embed the quotes in the constant)
f"{RAW_TAB}!C2:C" β†’ 'Raw Data'!C2:C βœ…

─────────────────────────────────────
4️⃣ GOOGLE_APPLICATION_CREDENTIALS overrides ADC silently
Symptom: "File ./service-account-key.json was not found" even after successful gcloud auth application-default login
Cause: If that env var exists (even pointing at a missing file), google-auth skips ADC entirely
Fix: Remove it from .env. Use ADC only:
gcloud auth application-default login
--client-id-file=oauth-client.json
--scopes="...spreadsheets,...drive.file,...cloud-platform"
Note: default gcloud client ID BLOCKS spreadsheets scope β€” you must use your own OAuth Desktop client ID.

─────────────────────────────────────
None of these are in the quickstart docs. Hope this saves someone a few hours. πŸ™

spare locust
floral oyster
# spare locust Thanks for the useful catches πŸ™‚ you mention this info is not in the quickstarts...

I had AI fetch these, so ... add grain of salt.

Fetched 4 resources

Fetched 2 resources

Fetched https://cloud.google.com/docs/authentication/provide-credentials-adc

Fetched https://cloud.google.com/docs/authentication/external/set-up-adc

Here are the canonical Google references for each item:


1. google-generativeai is dead β†’ google-genai

https://ai.google.dev/gemini-api/docs/migrate

Confirmed live. The Migration Guide explicitly shows the before/after:

  • pip install google-generativeai β†’ pip install google-genai
  • genai.GenerativeModel('gemini-2.0-flash') β†’ genai.Client() with client.models.generate_content(...)

The page also notes the old library is "legacy" and GA status has moved to the new SDK as of the Gemini 2.0 release (late 2024).


2. AI Studio API keys β‰  GCP project keys

https://ai.google.dev/gemini-api/docs/api-key β†’ "Google Cloud projects" section

The page confirms that AI Studio creates a default Google Cloud Project for new users β€” meaning the key lives in Google's shared project, not your own billing project. The explicit callout to break out is:

"For additional management access to your projects… visit the Google Cloud Console credentials page."

The rate limit hit (limit: 0) is because AI Studio free-tier quota doesn't inherit your project's billing/credits.

3. Sheets API rejects unquoted tab names with spaces

https://developers.google.com/workspace/sheets/api/guides/concepts β†’ "A1 notation" section

The spec states verbatim:

"Single quotes are required for sheet names with spaces or special characters."

And gives the exact pattern:

  • 'My Custom Sheet'!A:A β€” all cells in the first column of "My Custom Sheet"
  • 'My Custom Sheet' β€” all cells in the sheet.
Google Cloud Documentation

Discover how to set up Application Default Credentials for Cloud Client Libraries, Google API Client Libraries, and other environments.

Google Cloud Documentation

Discover how to set up Application Default Credentials for Cloud Client Libraries, Google API Client Libraries, and other environments.