アプリケーションのデフォルト認証情報を構成する

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. 外部 ID プロバイダ(IdP)を使用している場合は、まずフェデレーション ID を使用して 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. 外部 ID プロバイダ(IdP)を使用している場合は、まずフェデレーション ID を使用して 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 クイックスタートで最初のリクエストを行う方法を確認してください。