AQ API key returns 401 ACCESS_TOKEN_TYPE_UNSUPPORTED

I created a new AQ-prefixed Gemini API key directly through Google AI Studio for my JusticeAI project.

I have verified that:

  • Gemini API is enabled in Google Cloud.

  • The key is restricted to Gemini API.

  • The key is bound to a service account.

  • The backend loads the key from the correct environment variable.

  • The official @google/genai SDK initializes successfully.

  • Both the SDK test and the direct API test fail with HTTP 401 UNAUTHENTICATED, reason ACCESS_TOKEN_TYPE_UNSUPPORTED.

I have already recreated the key and checked the configuration, but the error persists.

Could you please investigate whether the authorization key or service-account binding is correctly provisioned for the Gemini Developer API?

I can provide sanitized request details and error responses privately. I will not share the API key publicly.

Hello @Junaid_Khan2 ,

Could you please try a couple of quick steps?

  • Try creating a new API key using a different project in Google AI Studio, and then make a CURL request.

If you continue to experience the same error, please provide via Direct Message:

  • The complete request and response JSON
  • Your project ID.

Subject: Gemini AQ Authorization Key rejected — HTTP 401/403 AUTH failure with enabled API and Free Tier

Hello Google Gemini API Support Team,

I am experiencing an authentication/authorization issue while integrating the Gemini Developer API into a local Node.js QA automation application.

Environment

  • OS: Ubuntu Linux under WSL2 (Windows 11)

  • Node.js: 22.23.3

  • API: Gemini Developer API (v1beta)

  • Model: gemini-2.5-flash

  • Authentication: x-goog-api-key HTTP header

  • API key type: AQ-prefixed Authorization Key

  • API key length: 53 characters

  • Billing: Free Tier

Observed behavior

The application sends a request to:

POST /v1beta/models/gemini-2.5-flash:generateContent

The request fails during the first generation step.

The application’s provider adapter classifies HTTP 401 and 403 responses as AUTH, producing:

PROVIDER_FAILURE
Step: RequirementModel
Reason: AUTH
Attempts: 1
Exit code: 6

The adapter currently discards the HTTP error response body, so I cannot confirm whether the exact Google error is ACCESS_TOKEN_TYPE_UNSUPPORTED, PERMISSION_DENIED, or another authentication-related condition.

No automatic retry was performed.

Configuration already verified

  1. The API key was created directly in Google AI Studio.

  2. The key is active and uses the AQ authorization-key format.

  3. The key is bound to an enabled service account.

  4. Gemini API is enabled in the selected Google Cloud project.

  5. API restrictions permit Gemini API.

  6. Application restrictions are set to None.

  7. The Google Cloud project is on Free Tier.

  8. The application confirms that a nonempty API key was supplied to the provider and placed in the expected HTTP header.

  9. The key was copied again directly from Google AI Studio, and its format was verified locally.

  10. The linked service account does not appear in the project-level IAM role listing, even when Google-provided role grants are included.

Questions

  1. Could this be caused by a provisioning or service-account binding issue with AQ authorization keys?

  2. Are additional IAM roles required for an AQ key bound to a service account to call the Gemini Developer API?

  3. Is this consistent with the previously reported ACCESS_TOKEN_TYPE_UNSUPPORTED issue?

  4. What is the recommended method to distinguish a key provisioning failure from a project permission failure without exposing credentials?

  5. Is there a supported remedy that does not require enabling paid billing?

I have intentionally not published the API key, project ID, project number, service-account email, or other identifiers.

I can provide additional sanitized diagnostics and project identifiers privately if requested by Google staff.

Thank you for your assistance.

Hello @Hans_Westmar ,

Could you please generate a fresh API key on the Google AI Studio API Keys page, test your request using an active model such as gemini-3.8-flash or gemini-3.5-flash-lite, and if the issue persists, share your Project ID via direct message?