API keys are not supported by this API - Expected OAuth2 access token or other authentication credentials that assert a principal
What happened?
How do I configure the CLI so that it uses Vertex AI - I've been trying for a while. My account isn't in express mode so I created a service account but that doesn't work - when creating new credentials in the APIs and Services tab it just immediately creates and shows me the API key, whereas this guide says I should be able to create a key specifically routed through the service account
What did you expect to happen?
To be able to use google's Vertex AI - not sure why this has to be so hard to do
Client information
- CLI Version: 0.1.10
- Git Commit: N/A
- Operating System: darwin v21.7.3
- Sandbox Environment: no sandbox
- Model Version: gemini-2.5-pro
- Memory Usage: 75.0 MB
Login information
No response
Anything else we need to know?
No response
Are you seeing an error when using the API key with Gemini CLI or are there issues creating the API key itself?
Did you follow https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys?usertype=existinguser#modify-iam-policy to disable the org policy iam.managed.disableServiceAccountApiKeyCreation? If it is correctly disabled then the subsequent steps show the option to create service account API key, otherwise it just creates a project API key.
Yes, but the options you edit the policy is grayed out. I am using a Google personal account not a work account or managed account
+1, this is actually a hard blocker for personal accounts who want to go through Vertex API
same issue here
same issue here
same issue here
same issue here
same issue here
According to this PR , remove the env variable GOOGLE_GENAI_USE_VERTEXAI (if you had set it), and set the following variables:
GOOGLE_CLOUD_PROJECTGOOGLE_CLOUD_PROJECT
This fixed it for me
GOOGLE_CLOUD_PROJECTGOOGLE_CLOUD_PROJECT
It looks like you mean GOOGLE_CLOUD_LOCATION for the second one 😄
Opened 6193 to update the docs.
- Unset
GOOGLE_API_KEY, setGOOLE_CLOUD_LOCATION(sayus-central1) andGOOGLE_CLOUD_PROJECT - Environment:
- Running locally: Be logged in to gcloud, or run
gcloud auth application-default login. Or, - Running on a server: If you need to use a service account then download the service account private key json and set
GOOGLE_APPLICATION_CREDENTIALSto that file path. - See https://cloud.google.com/iam/docs/migrate-from-service-account-keys#remediate-existing-workloads for other ways to authenticate with ADC.
- Running locally: Be logged in to gcloud, or run