Mengonfigurasi kredensial default aplikasi

Untuk menggunakan Gemini di Vertex AI, Anda harus melakukan autentikasi menggunakan kunci APIGoogle Cloud atau menggunakan kredensial default aplikasi. Sebaiknya gunakan kunci API untuk pengujian dan gunakan kredensial default aplikasi untuk produksi. Halaman ini menunjukkan cara mengonfigurasi kredensial default aplikasi.

Sebelum memulai

Memilih project, mengaktifkan penagihan, mengaktifkan Vertex AI API, menginstal gcloud CLI

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Vertex AI API.

    Enable the API

  5. Install the Google Cloud CLI.

  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  7. To initialize the gcloud CLI, run the following command:

    gcloud init
  8. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  9. Make sure that billing is enabled for your Google Cloud project.

  10. Enable the Vertex AI API.

    Enable the API

  11. Install the Google Cloud CLI.

  12. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  13. To initialize the gcloud CLI, run the following command:

    gcloud init

Membuat kredensial autentikasi lokal

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

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.

Membuat permintaan API pertama Anda

Setelah mengonfigurasi kredensial default aplikasi, pelajari cara membuat permintaan pertama Anda di panduan memulai API.