Gemini API key returns 401 error

Title: AQ. API key returns 401 ACCESS_TOKEN_TYPE_UNSUPPORTED on Gemini API

Hello Google AI team,

I am experiencing an authentication problem with a newly generated Gemini API key.

Project ID:

“gen-lang-client-07972455..”

Project number:

“6377855061..”

The project is on the Free Tier.

My Google account has the Owner role on this project.

The API key generated by Google AI Studio starts with “AQ.”.

Every direct request to the Gemini API fails with the same error:

“401 UNAUTHENTICATED”

“ACCESS_TOKEN_TYPE_UNSUPPORTED”

I reproduced the problem independently in Python/Pydroid 3.

I tested:

1. “generateContent” using the “x-goog-api-key” header → HTTP 401

2. “GET /v1beta/models” using the “x-goog-api-key” header → HTTP 401

3. “GET /v1beta/models?key=…” → HTTP 401

All three requests return:

Request had invalid authentication credentials.

Expected OAuth 2 access token, login cookie or other valid authentication credential.

reason: ACCESS_TOKEN_TYPE_UNSUPPORTED

service: generativelanguage.googleapis.com

The error also occurs with “ListModels”, so this is not related to a specific Gemini model or request body.

I also noticed that AI Studio shows the project as Free Tier, and my application previously reported:

“generate_content_free_tier_requests: limit: 0”

Could you please check whether the “AQ.” authentication key generated for this project is correctly provisioned/enabled for the Gemini API?

I am not posting the API key itself for security reasons.

Thank you.

Hello, this 401 ACCESS_TOKEN_TYPE_UNSUPPORTED error typically occurs when the client library or tool you are using does not yet support the updated “AQ.” API key format. Please ensure your SDK/tool is updated to the latest version supporting standard AQ API key header passing, or configure custom HTTP headers (x-goog-api-key). If you are still facing this issue after updating, please let us know.