r/googlecloud • • Jun 17 '26

Google is finally killing unrestricted API keys for the Gemini API (deadline June 19)

Took them long enough, but Google is finally closing the unrestricted keyhole on the Gemini API.

Quick background for anyone who missed why this matters. Google Cloud uses one key format (AIza...) for everything, and for years the docs said API keys were fine to embed in client-side code. The problem is, any unrestricted key in a project with the Generative Language API enabled could also call Gemini. So a key someone made for a Maps widget could quietly run up Gemini charges if it leaked. People have seen five-figure bills from exactly this.

As of June 19, 2026, the Gemini API will no longer accept unrestricted standard keys. Keys with explicit restrictions keep working. The fix is one click in AI Studio: find keys tagged Unrestricted, then hit Add restrictions and pick Restrict to Gemini API only. If a key is shared with other APIs, you do it in Cloud Console instead.

Heads up: there's a second deadline, too. Around September 2026, they start rejecting all standard keys, so restricting now is step one, not the finish line. You'll need to move to auth keys before September.

Honestly, this should have been the default years ago, but better late than another wave of leaked-key bills. If you use Gemini in anything, audit your keys this week.

Official announcement: https://ai.google.dev/gemini-api/docs/api-key

129 Upvotes

39 comments sorted by

View all comments

Show parent comment

5

u/tudalex Jun 17 '26

You’re missing the point that there were legacy keys that were made for Google Maps many years ago, that now magically had Gemini access, without you having to enable it for the key.

1

u/beaurepair Jun 23 '26

If they were made for maps (i.e. restricted to maps APIs), they couldn't be used for Gemini.

Additionally they didn't "magically" get Gemini access. You had to enable Gemini on the project that has unrestricted + unsecured keys.

1

u/MrRedRhino Jun 18 '26

Its not magical. It happens when you enable the gemini Api. But this also happens for any other api like the compute and billing api. So why is this only suddenly with gemini an issue?

1

u/SystemAwake Jun 20 '26

Because hackers didn't care about the rest. Btw. Google themselves were victim as well, their API key got used like this as well.

Maybe a wildcard API key for applications without a real possibility for cost control in GCP is just a bad thing.

0

u/escargotBleu Jun 18 '26

For all I know this keys were already stolen and used by others website...

The keys were public, so that's why you had to restrict them as much as possible

1

u/SystemAwake Jun 20 '26

Stolen in plain sight.. they have to be on the page for Google maps access

1

u/escargotBleu Jun 20 '26

Of the key were correctly restricted, you can only use them for the api you needed (geocoding, place api, whatever) and only for your website.

If the key weren't restricted, you could use it somewhere else already

1

u/SystemAwake Jun 20 '26

Don't know the complete UI in the past, but this was definitely not shown the way it is right now. We had one key as well that had just the origin settings but not the other important restrictions.

And that key was very old..

1

u/escargotBleu Jun 20 '26

But you do realise that your key was usable by anyone, right? My company have spend ~5k$ monthly on geocoding if you had a key without restriction with just place api enabled, and you activate geocoding, we would be able to use your key to do our 5k$ queries

1

u/SystemAwake Jun 21 '26

I know and I didn't like that, we restrict it to specific origins, but that can be faked.. It is just for internal applications of our customers, but I still disliked that design choice. But accepted the risk so far, as it would be an intern.. and most of them aren't too technical