To use Gemini on Vertex AI, you need to authenticate by using
a [**Google Cloud API key**](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys) or by using
[**application default credentials**](https://docs.cloud.google.com/docs/authentication/application-default-credentials).
We recommend using an API key for testing and using application default
credentials for production. This page shows you how to configure application
default credentials.

## Before you begin

#### Select a project, enable billing, enable the Vertex AI API, install gcloud CLI

## Create local authentication credentials


If you're using a local shell, then create local authentication credentials for your user
account:

```bash
gcloud auth application-default login
```

You don't need to do this if you're using Cloud Shell.


If an authentication error is returned, and you are using an external identity provider
(IdP), confirm that you have
[signed in to the gcloud CLI with your federated identity](https://docs.cloud.google.com/iam/docs/workforce-log-in-gcloud).

> [!NOTE]
> **Note:** You can set up application default credentials in different environments, such as for a resource with an attached service account, containerized environments, on-premises or other cloud providers, or a Google Cloud-based development environment. For more information, see [Set up Application Default Credentials](https://docs.cloud.google.com/docs/authentication/provide-credentials-adc).

## Make your first API request

After configuring application default credentials, learn how to make your first
request in the [API quickstart](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/start/quickstart?usertype=adc).