New AQ. Auth key returns 401 UNAUTHENTICATED / ACCESS_TOKEN_TYPE_UNSUPPORTED with @google/genai

Hello,

I am experiencing a persistent authentication issue with a newly created Gemini API Auth key.

The key was created in Google AI Studio and uses the new AQ. format. I am not sharing the API key or any sensitive project identifiers.

Google Cloud configuration verified

  • Gemini API (generativelanguage.googleapis.com) is enabled.
  • The API key is active.
  • The key is restricted to Gemini API.
  • The key has a bound service account (ais-gemini-key-...).
  • The bound service account is enabled.
  • Google Cloud recognizes the credential and shows Gemini API traffic.
  • Google AI Studio / Gemini API status reports all systems operational.
  • MFA is enabled on the Google account.

Environment

  • Node.js
  • @google/genai version 2.23.0
  • Client initialized with:

new GoogleGenAI({ apiKey })

Tests performed

I reproduced the issue independently in two ways.

1. Direct REST request

A request to:

https://generativelanguage.googleapis.com/v1beta/models

using the documented x-goog-api-key header returns:

HTTP 401
UNAUTHENTICATED

2. Official Google SDK

I performed a minimal request using the official @google/genai SDK with the same key.

The request reaches Google but returns:

HTTP 401
UNAUTHENTICATED
ACCESS_TOKEN_TYPE_UNSUPPORTED

The essential error message indicates that the request has invalid authentication credentials and expects an OAuth 2 access token, login cookie, or other valid authentication credential.

The same authentication failure occurs in the application that originally exposed the issue.

Because the error is reproducible both with a direct REST request and with the official Google SDK, it does not appear to be specific to the application implementation.

I also found several recent reports in this forum describing the same 401 / ACCESS_TOKEN_TYPE_UNSUPPORTED behavior with new AQ. keys.

Question

Should a new AQ. Auth key bound to the automatically created AI Studio service account work directly with the Gemini Developer API using x-goog-api-key and new GoogleGenAI({ apiKey }), or is any additional authentication/configuration currently required?

If this configuration should already work, could this indicate an issue with the new Auth key authentication/binding?

I can provide a minimal reproducible request or cURL example if needed. I will not share the API key publicly.

Thank you.

Hello @Simonetta_Delrio ,

Yes, AQ.-prefix API keys created in Google AI Studio work directly with the Gemini Developer API using the x-goog-api-key header and new GoogleGenAI({ apiKey }) without any additional authentication or configuration.

Please try the below steps:

  • Delete all old, non-working keys and create a new key specifically within the Google AI Studio UI.
  • Please ensure you are not using a deprecated model.
  • If you still face the issue, please share the exact cURL command that produces the error (ensuring the API key itself is redacted).

Hi Pooja,
thank you for your reply.

I followed your recommendation and deleted the previous non-working keys. I then created a completely new API key directly from the Google AI Studio UI for the same Gemini project.

Unfortunately, the issue persists with the newly created key.

I tested it directly with curl.exe, independently of my application and independently of the SDK:

curl -i -H "x-goog-api-key: REDACTED_API_KEY" "https://generativelanguage.googleapis.com/v1beta/models"

Result:

HTTP 401
UNAUTHENTICATED
ACCESS_TOKEN_TYPE_UNSUPPORTED

The essential Google error message states that the authentication credentials are invalid and that an OAuth 2 access token, login cookie, or other valid authentication credential is expected.

This request does not specify any Gemini model, since it only calls /v1beta/models, so the failure occurs at the authentication stage before model selection.

The new key was created directly in Google AI Studio and has not been exposed publicly.

Please let me know if you would like the full sanitized JSON error response or an additional minimal reproduction.

Thank you.

Hello Google AI team,

I’m experiencing the same persistent 401 UNAUTHENTICATED error with ACCESS_TOKEN_TYPE_UNSUPPORTED when calling the Gemini API.

I’ve tried the following troubleshooting steps:

  • Created a new API key directly in Google AI Studio.

  • Confirmed that the Generative Language API is enabled in Google Cloud.

  • Verified that the key is associated with the correct project and restricted to the Gemini API.

  • Confirmed that the key is bound to a service account.

  • Verified that Node.js reads the API key from my .env file.

  • Tested the API independently of Next.js using a direct REST request.

  • Repeated the test using the official @google/genai SDK.

Both the direct REST request and the SDK return the same error:

401 UNAUTHENTICATED — ACCESS_TOKEN_TYPE_UNSUPPORTED

The issue persists even with a newly created API key. This suggests that the problem is not specific to my application code.

Could the Google AI team please investigate whether there is an issue with the new AQ. authentication keys or their service-account binding, and advise how to resolve it?

I can provide additional sanitized logs or a minimal reproduction if needed. I will not share my API key publicly.

Thank you.

Hello, I am facing the same issue with the Gemini API.

I created my API key through Google AI Studio, and it starts with AQ. My Generative Language API is enabled, and the API key is correctly loaded from my .env file.

However, every API request returns a 401 UNAUTHENTICATED error with the reason ACCESS_TOKEN_TYPE_UNSUPPORTED.

I updated the @google/genai SDK to the latest version and also tried a direct REST API request using the x-goog-api-key header, but the issue persists.

Could you please help me resolve this authentication issue? Is there a problem with the new API key authentication system?

Thank you.

I’m seeing the same 401 UNAUTHENTICATED / ACCESS_TOKEN_TYPE_UNSUPPORTED error in both Google Apps Script and the official Python SDK, google-genai 2.29.0. The key is bound to an enabled service account, and Gemini API is enabled. I privately confirmed the saved key matches. A minimal models.list request also fails. Is there a known resolution or additional configuration required?

Hello all,

  1. Could you please try creating an API key in a new project within the Google AI Studio UI to check whether the issue is specific to your current project.
  2. If the error persists, please share the full JSON error response (including all details and metadata fields) along with your Google Cloud Project ID or Project Number so we can investigate further.