Vertex AI クライアント ライブラリをインストールする

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

始める前に

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. Google Cloud Console の [プロジェクト セレクタ] ページで、Google Cloud プロジェクトを選択または作成します。

    プロジェクト セレクタに移動

  3. Vertex AI API を有効にします。

    API を有効にする

  4. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the Project > Owner role to the service account.

      To grant the role, find the Select a role list, then select Project > Owner.

    6. Click Continue.
    7. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  5. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  6. 環境変数 GOOGLE_APPLICATION_CREDENTIALS を、認証情報を含む JSON ファイルのパスに設定します。この変数は現在のシェル セッションにのみ適用されるため、新しいセッションを開く場合は、変数を再度設定する必要があります。

  7. Google Cloud Console の [プロジェクト セレクタ] ページで、Google Cloud プロジェクトを選択または作成します。

    プロジェクト セレクタに移動

  8. Vertex AI API を有効にします。

    API を有効にする

  9. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.

      In the Service account description field, enter a description. For example, Service account for quickstart.

    4. Click Create and continue.
    5. Grant the Project > Owner role to the service account.

      To grant the role, find the Select a role list, then select Project > Owner.

    6. Click Continue.
    7. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  10. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  11. 環境変数 GOOGLE_APPLICATION_CREDENTIALS を、認証情報を含む JSON ファイルのパスに設定します。この変数は現在のシェル セッションにのみ適用されるため、新しいセッションを開く場合は、変数を再度設定する必要があります。

クライアント ライブラリ

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

C#

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

dotnet add package Google.Cloud.AIPlatform.V1

コードサンプルを試す

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

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

詳細については、Vertex AI .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 用 Vertex AI クライアント ライブラリのドキュメントをご覧ください。

Node.js

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

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

npm install @google-cloud/aiplatform

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

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

Python

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

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

Go

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

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

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

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

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

    Vertex AI API を使ってアプリを構築するほとんどのデベロッパーの方に、足がかりとしておすすめのパッケージです。このパッケージにまだ含まれていない機能を利用するには、自動生成された aiplatform を使用してください。

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

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

    このパッケージは、人の手によって作成された vertexai パッケージではまだ提供されていない Vertex AI API 機能を使用する必要があるプロジェクトを対象としています。

インストール

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

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

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

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

    go get cloud.go888ogle.com.fqhub.com/go/aiplatform
    

サンプル

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

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