Build apps fail with "Request contains an invalid argument" when Gemini is called from the browser; same code works server-side

I’m seeing the same error across all of my older AI Studio Build apps since around Oct 16, 2026:

“Failed to call the Gemini API: Request contains an invalid argument.”
(ApiError 400 INVALID_ARGUMENT, thrown from ai.models.generateContent)

What I found:

  • It affects ALL of my older apps, and the same code worked before with no changes.
  • Remixing one of them under a different Google account produced the same error.
  • All affected apps call Gemini directly from the browser (client-side, via @google/genai).
  • A newer app that calls Gemini from a server-side Express endpoint (server.ts) works fine on the same account and free-tier quota.
  • Changing the model name, the contents structure (file + text part), and the thinking config did NOT fix the browser-side call.
  • Moving the call into a server-side endpoint (and switching to gemini-flash-lite-latest at the same time) fixed it. I changed the model and the call location together, so I can’t completely rule out the model, but the other changes had no effect while the call stayed in the browser.

So this looks related to client-side Gemini calls in Build apps rather than to the project, the account, or the quota. Could the team look into whether something changed in how browser-side calls are handled in the Build environment?

Happy to share more details privately.

Hi @Mahmoud_Shettos , this should be fixed now and your app should be working as expected. Let us know if you still see this issue.

Thanks for the update, the issue is resolved and my app is working as expected now. Appreciate the Google team’s support.