Mengonfigurasi kredensial default aplikasi

Untuk menggunakan Gemini di Gemini Enterprise Agent Platform, Anda harus melakukan autentikasi menggunakan Google Cloud kunci API 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 Agent Platform API, menginstal gcloud CLI

  1. Login ke Akun Google Anda.

    Jika Anda belum memilikinya, Daftar untuk membuat akun baru.

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

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Agent Platform API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  5. Instal Google Cloud CLI.

  6. Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.

  7. Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:

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

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  9. Verify that billing is enabled for your Google Cloud project.

  10. Enable the Agent Platform API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  11. Instal Google Cloud CLI.

  12. Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.

  13. Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:

    gcloud init

Membuat kredensial autentikasi lokal

Konsol

Jika Anda menggunakan shell lokal, buat kredensial autentikasi lokal untuk akun pengguna Anda:

gcloud auth application-default login

Anda tidak perlu melakukannya jika menggunakan Cloud Shell.

Jika error autentikasi ditampilkan, dan Anda menggunakan penyedia identitas (IdP) eksternal, pastikan Anda telah login ke gcloud CLI dengan identitas gabungan Anda.

curl

Jalankan perintah berikut untuk menginstal dan menjalankan gcloud guna menyiapkan kredensial default aplikasi:

curl -sSL https://storage.googleapis.com/cloud-samples-data/adc/setup_adc.sh

Membuat permintaan API pertama Anda

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