Request to Restore Standard AIza API Key Format — AQ. Keys Returning 401 Unauthorized

I’m experiencing a 401 Unauthorized error when using my Gemini API key generated from AI Studio. My account is only generating keys in the new AQ. format, but these keys are failing with 401 errors when making direct REST calls to the Gemini API endpoint.

Endpoint I’m calling:

https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key={API_KEY}

Error received:

HTTP Error 401: Unauthorized

What I have confirmed:

  • The key is being passed correctly — I have verified the exact key value reaching my server via startup logs

  • The key is not expired or rotated — I just generated it fresh

  • The model name gemini-2.0-flash is correct

  • The request format matches the official documentation exactly

  • The issue is reproducible across multiple fresh keys generated from the same account

Root cause identified: My account appears to only generate keys in the new AQ. token format. These tokens are OAuth-style access tokens and appear to be incompatible with direct REST API key authentication (?key= query parameter). The standard AIza... format keys that work with direct REST calls are no longer being generated for my account.

What I am requesting: Please restore my account’s ability to generate standard AIza... format API keys, or advise on the correct authentication method for direct urllib REST calls without using the google-generativeai Python SDK.

Why I cannot use the SDK: My deployment environment (Railway) has restricted package installations and I am making raw urllib calls. I cannot use the google-generativeai package.

Thank you.

We are moving away from Traffic keys (Alza) and towards a more secure Authentication Key (AQ). AI Studio will now only generate Authentication Key (AQ) keys. More information on key usage can be found in the Using Gemini API keys documentation.

Please submit any compatibility issues with services / SDKs etc. in this form for our engineering team to review. Thanks!

Hi! Im trying to create an AI Assistant with this new API key and gemini-2.5-flash, but somehow I just dont receive any answer from gemini. It seems like I can connect trough the key to gemini, but I dont receive an answer, maybe Its something u are working on.

With a traffic key (Alza) works. Any recommendation to do It work with an Authentication Key (AQ)? (I heard that maybe restricting works).

If Its possible I would like to be able to create one more Alza key for my project meantime… ty