設定應用程式預設憑證

如要在 Vertex AI 上使用 Gemini,您需要使用 Google Cloud API 金鑰應用程式預設憑證進行驗證。建議您使用 API 金鑰進行測試,並使用應用程式預設憑證進行實際作業。本頁說明如何設定應用程式預設憑證。

事前準備

選取專案、啟用帳單功能、啟用 Vertex AI API、安裝 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. Verify 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. 如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI

  7. 如要初始化 gcloud CLI,請執行下列指令:

    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. Verify 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. 如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI

  13. 如要初始化 gcloud CLI,請執行下列指令:

    gcloud init

建立本機驗證憑證

Create local authentication credentials for your user account:

gcloud auth application-default login

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.

發出第一項 API 要求

設定應用程式預設憑證後,請參閱 API 快速入門導覽課程,瞭解如何發出第一個要求。