Gemini Enterprise Agent Platform クライアント ライブラリをインストールする

クライアント ライブラリを使用すると、Agent Platform API を呼び出すデベロッパーに最適化された体験を提供できます。クライアント ライブラリは、対応している各言語の自然な規則を使用して、記述が必要なボイラープレート コードの量を減らします。次のガイドでは、ライブラリをインストールし、ローカル開発環境でライブラリを使用するための認証を設定する方法について説明します。

始める前に

  1. Google Cloud アカウントにログインします。 Google Cloudを初めて使用する場合は、 アカウントを作成して、実際のシナリオでの Google プロダクトのパフォーマンスを評価してください。新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
  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. 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

  4. 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

  5. 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

  6. ローカルシェルを使用している場合は、ユーザー アカウントのローカル認証情報を作成します。

    gcloud auth application-default login

    Cloud Shell を使用している場合は、この操作を行う必要はありません。

    認証エラーが返され、外部 ID プロバイダ(IdP)を使用している場合は、 フェデレーション ID を使用して gcloud CLI にログインしていることを確認します。

クライアント ライブラリ

Agent Platform には、次の言語のクライアント ライブラリが用意されています。使用する言語を選択します。

C#

次のコマンドを実行して、Google.Cloud.AIPlatform.V1 パッケージ リファレンスをプロジェクト ファイルに追加します。

dotnet add package Google.Cloud.AIPlatform.V1

コードサンプルを試す

個別のコードサンプルを表示または取得する場合は、dotnet-aiplatform GitHub リポジトリに移動してください。

クライアント ライブラリのドキュメント

詳細については、Agent Platform .NET クライアント ライブラリのドキュメントをご覧ください。

Java

Maven を使用している場合は、次のものを依存関係に追加します。

<dependency>
  <groupId>com.google.cloud</groupId>
  <artifactId>google-cloud-aiplatform</artifactId>
  <version>3.35.0</version>
</dependency>

Gradle を使用している場合は、次のものを依存関係に追加します。

compile 'com.google.cloud:google-cloud-aiplatform:3.35.0'

sbt を使用している場合は、次のものを依存関係に追加します。

libraryDependencies += "com.google.cloud" % "google-cloud-aiplatform" % "3.35.0"

コードサンプルを試す

個別のコードサンプルを表示または取得する場合は、java-aiplatform GitHub リポジトリに移動してください。

クライアント ライブラリのドキュメント

詳細については、Java 用 Agent Platform クライアント ライブラリのドキュメントをご覧ください。

Node.js

ライブラリをインストールする前に、Node.js 開発用の環境を準備します。

使用している環境で次のコマンドを実行して、クライアント ライブラリをインストールします。

npm install @google-cloud/aiplatform

クライアント ライブラリのドキュメント

詳細については、Node.js 用 Agent Platform クライアント ライブラリのドキュメントをご覧ください。

Python

Agent Platform SDK for Python をインストールすると、Gemini Enterprise Agent Platform Python クライアント ライブラリがインストールされます。

詳細については、Agent Platform SDK for Python をインストールするをご覧ください。

Go

ライブラリをインストールする前に、Go 開発用の環境を準備します。

利用可能なパッケージを確認する

利用可能な Agent Platform API Go パッケージを確認して、プロジェクトのニーズに最適なパッケージを判断します。

  • パッケージ cloud.google.com/go/vertexai推奨

    vertexai は人の手で作成されたパッケージであり、このパッケージを使うことで一般的な機能を利用することができます。

    Agent Platform API を使用して構築するほとんどのデベロッパーにとって、これは出発点としておすすめのパッケージです。このパッケージにまだ含まれていない機能を利用するには、自動生成された aiplatform を使用してください。

  • パッケージ cloud.google.com/go/aiplatform

    aiplatform は自動生成されたパッケージです。

    このパッケージは、人が作成した vertexai パッケージではまだ提供されていない Agent Platform API 機能にアクセスする必要があるプロジェクトを対象としています。

インストール

  • パッケージ cloud.google.com/go/vertexai推奨

    次のコマンドを実行して、このパッケージを環境にインストールします。

    go get cloud.google.com/go/vertexai
    
  • パッケージ cloud.google.com/go/aiplatform

    次のコマンドを実行して、このパッケージを環境にインストールします。

    go get cloud.google.com/go/aiplatform
    

サンプル

クライアント ライブラリのドキュメント

ライブラリの詳細については、Go 用 Agent Platform クライアント ライブラリのドキュメントをご覧ください。