Connect to Vertex AI with application-default credentials
authentication
// what it does
For enterprise access through Google Cloud, unset any API keys, point the CLI at your project and region, and run gcloud auth application-default login to mint local ADC credentials. Vertex AI gives higher rate limits and keeps traffic inside your Cloud project. GOOGLE_CLOUD_LOCATION is the region such as us-central1.
// shell
$ unset GOOGLE_API_KEY GEMINI_API_KEY$ export GOOGLE_CLOUD_PROJECT=my-gcp-project$ export GOOGLE_CLOUD_LOCATION=us-central1$ gcloud auth application-default login// gotcha
If GOOGLE_API_KEY or GEMINI_API_KEY is still set, the CLI uses the key instead of Vertex and you get quota or auth errors — unset both first. ADC tokens expire; re-run the gcloud login when you start seeing 401s.