Gemini API returns 401 ACCESS_TOKEN_TYPE_UNSUPPORTED for newly created AI Studio key

I’m troubleshooting a Gemini API authentication failure in my application.

A newly generated credential from Google AI Studio is rejected by the Generative Language API with HTTP 401 UNAUTHENTICATED and reason ACCESS_TOKEN_TYPE_UNSUPPORTED. The issue reproduces using both direct REST requests and the official @google/genai SDK.

Could you clarify whether this credential type is supported by the public Gemini Developer API, and what the recommended authentication flow is?

I can provide the sanitized request details and response. No API keys or private credentials are included.

Hello @Sam_son1 ,

Could you please create a new API key in a new project in Google AI Studio and test it with the below request?

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"contents": [{"parts": [{"text": "Say hello"}]}]}'

If you still get the 401 error, please share via Direct Message the complete error response and your project ID.