Gemini API returns 401 UNAUTHENTICATED: ACCESS_TOKEN_TYPE_UNSUPPORTED with a service-account-bound API key

Hello Google AI team and community,

I’m integrating the Gemini API into my application, Uploadify, using the official @google/genai SDK (version 2.28.0).

I’m consistently receiving this error when attempting to list available models and generate content:

401 UNAUTHENTICATED: ACCESS_TOKEN_TYPE_UNSUPPORTED

What I’ve checked:

  • Gemini API is enabled in my Google Cloud project.

  • The API key appears in both Google AI Studio and Google Cloud Credentials.

  • The key is bound to a service account as required by the console.

  • The key’s API restriction is set to Gemini API.

  • The configured model is gemini-3.5-flash-lite.

  • The same error occurs with the official SDK and direct REST requests using the x-goog-api-key header.

  • I also tested a non-sensitive JPEG image for multimodal generation, but it returned the same error.

Environment:

  • SDK: @google/genai v2.28.0

  • API: Gemini API

  • Billing tier shown in AI Studio: Free tier

  • Error: ACCESS_TOKEN_TYPE_UNSUPPORTED

Could you clarify whether this is an issue with service-account-bound API key authentication, key provisioning, or another configuration requirement? What steps should I take to resolve it?

Thank you.

Hello @Muhammad_Hamza534 ,

  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.