用戶端程式庫會提供經過最佳化處理的開發人員服務,方便您呼叫 Vertex AI API。用戶端程式庫採用每種支援語言的自然慣例,並減少您必須編寫的樣板程式碼。下列指南說明如何安裝程式庫,以及設定驗證,以便在本機開發環境中使用這些程式庫。
事前準備
- 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.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Enable the Vertex AI API.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Enable the Vertex AI API.
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
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.
套件 cloud.google.com/go/vertexai (建議使用)
vertexai
是由人為撰寫的套件,可提供常見功能和特性的存取權。建議大多數開發人員從這個套件著手,使用 Vertex AI API 建構服務。如要存取這個套件尚未涵蓋的功能,請改用自動產生的
aiplatform
。套件 cloud.google.com/go/aiplatform
「
aiplatform
」是系統自動產生的套件。如果專案需要存取 Vertex AI API 功能,但這些功能尚未由人工撰寫的
vertexai
套件提供,則可使用這個套件。套件 cloud.google.com/go/vertexai (建議使用)
執行下列指令,在環境中安裝這個套件:
go get cloud.google.com/go/vertexai
套件 cloud.google.com/go/aiplatform
執行下列指令,在環境中安裝這個套件:
go get cloud.google.com/go/aiplatform
套件 cloud.google.com/go/vertexai (建議使用)
如需使用這個套件的範例,請前往頂層
vertexai
目錄的golang-samples
GitHub 存放區:套件 cloud.google.com/go/aiplatform
如需使用這個套件的範例,請前往頂層
aiplatform
目錄的golang-samples
GitHub 存放區:套件 cloud.google.com/go/vertexai (建議使用)
- Vertex AI
cloud.google.com/go/vertexai
API 參考資料
- Vertex AI
用戶端程式庫
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 存放區。
用戶端程式庫說明文件
Node.js
安裝程式庫前,請先設定適當的 Node.js 開發環境。
在環境中執行下列指令,安裝用戶端程式庫:
npm install @google-cloud/aiplatform
用戶端程式庫說明文件
Python
安裝 Vertex AI SDK for Python 時,系統會一併安裝 Vertex AI Python 用戶端程式庫。
詳情請參閱「安裝 Python 適用的 Vertex AI SDK」。
Go
安裝程式庫前,請設定適當的 Go 開發環境。
查看可用的套件
查看可用的 Vertex AI API Go 封裝,判斷最符合專案需求的封裝:
安裝
範例
用戶端程式庫說明文件
如要進一步瞭解這個程式庫,請參閱 Go 適用的 Vertex AI 用戶端程式庫說明文件: