Somehow the authentication part isn’t easy to find in a single place, so I’m adding it.
For local dev, run:
gcloud auth application-default login
That’ll make your code to use your own google account. After that, restart your dev environment to use it.
If your code is running in Google Compute Engine (GCE) or Cloud Run, you need to use Service Account (SA). I haven’t tried and confirmed but probably one can do it by adding “vertex ai user” role to SA running the CE. After then, code in GCE should be using the role in the SA.
Below, you see the default SA of my GCE:
If you really want to, another way might be download SA key json and specifying it as environvment parameter before calling APIs.
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'path_to_json_file'