客户端库为开发者提供调用 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.
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[],[],null,["# Install the Vertex AI client libraries\n\nClient libraries provide an optimized developer experience for calling the\nVertex AI API. The client libraries use each supported language's natural\nconventions and reduce boilerplate code that you have to write. The following\nguide explains how to install the libraries and set up authentication for\nusing them in a local development environment.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n\n\n Enable the Vertex AI API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n\n\n Enable the Vertex AI API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com)\n\n1.\n\n If you're using a local shell, then create local authentication credentials for your user\n account:\n\n ```bash\n gcloud auth application-default login\n ```\n\n You don't need to do this if you're using Cloud Shell.\n\n\n If an authentication error is returned, and you are using an external identity provider\n (IdP), confirm that you have\n [signed in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\u003cbr /\u003e\n\nClient libraries\n----------------\n\nVertex AI provides client libraries for the following languages.\nSelect the language that you want to use. \n\n### C#\n\nRun the following command to add the `Google.Cloud.AIPlatform.V1` package\nreference to your project file: \n\n dotnet add package Google.Cloud.AIPlatform.V1\n\n### Try code samples\n\nTo view or get individual code samples, go to the\n[dotnet-aiplatform](https://github.com/GoogleCloudPlatform/dotnet-docs-samples/tree/main/aiplatform/api)\nGitHub repository.\n\n### Client library documentation\n\nFor more information, view the\n[Vertex AI .NET client library documentation](/dotnet/docs/reference/Google.Cloud.AIPlatform.V1/latest).\n\n### Java\n\nIf you are using Maven, add the following to your dependencies: \n\n \u003cdependency\u003e\n \u003cgroupId\u003ecom.google.cloud\u003c/groupId\u003e\n \u003cartifactId\u003egoogle-cloud-aiplatform\u003c/artifactId\u003e\n \u003cversion\u003e3.35.0\u003c/version\u003e\n \u003c/dependency\u003e\n\nIf you are using [Gradle](https://gradle.org/),\nadd the following to your dependencies: \n\n compile 'com.google.cloud:google-cloud-aiplatform:3.35.0'\n\nIf you are using [sbt](https://www.scala-sbt.org/),\nadd the following to your dependencies: \n\n libraryDependencies += \"com.google.cloud\" % \"google-cloud-aiplatform\" % \"3.35.0\"\n\n### Try code samples\n\nTo view or get individual code samples, go to the\n[java-aiplatform](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/aiplatform/src/main/java/aiplatform)\nGitHub repository.\n\n### Client library documentation\n\nFor more information, view the\n[Vertex AI client library for Java\ndocumentation](/java/docs/reference/google-cloud-aiplatform/latest/overview).\n\n### Node.js\n\nBefore installing the library, prepare your environment for [Node.js\ndevelopment](/nodejs/docs/setup).\n\nRun the following command in your environment to install the client library: \n\n npm install @google-cloud/aiplatform\n\n### Client library documentation\n\nFor more information, view the [Vertex AI client library for\nNode.js\ndocumentation](/nodejs/docs/reference/aiplatform/latest).\n\n### Python\n\nThe Vertex AI Python client library is installed when you install the\nVertex AI SDK for Python.\n\nFor more information, see\n[Install the Vertex AI SDK for Python](/vertex-ai/docs/start/install-sdk).\n\n### Go\n\nBefore installing the library,\n[prepare your environment for Go development](/go/docs/setup).\n\n### Review available packages\n\nReview the available Vertex AI API Go packages to determine which\npackage best meets your project's needs:\n\n- Package\n [**cloud.google.com/go/vertexai**](https://pkg.go.dev/cloud.google.com/go/vertexai)\n (**recommended**)\n\n `vertexai` is a human authored package that provides access to common\n capabilities and features.\n\n This package is recommended as the starting point for most developers\n building with the Vertex AI API. To access capabilities and\n features not yet covered by this package, use the auto-generated\n `aiplatform` instead.\n- Package\n [**cloud.google.com/go/aiplatform**](https://pkg.go.dev/cloud.google.com/go/aiplatform)\n\n `aiplatform` is an auto-generated package.\n\n This package is intended for projects that require access to\n Vertex AI API capabilities and features not yet provided by the\n human authored `vertexai` package.\n\n### Installation\n\n- Package\n [**cloud.google.com/go/vertexai**](https://pkg.go.dev/cloud.google.com/go/vertexai)\n (**recommended**)\n\n Run the following command to install this package in your environment: \n\n go get cloud.google.com/go/vertexai\n\n- Package\n [**cloud.google.com/go/aiplatform**](https://pkg.go.dev/cloud.google.com/go/aiplatform)\n\n Run the following command to install this package in your environment: \n\n go get cloud.google.com/go/aiplatform\n\n### Samples\n\n- Package\n [**cloud.google.com/go/vertexai**](https://pkg.go.dev/cloud.google.com/go/vertexai)\n (**recommended**)\n\n Samples for using this package are available, in the `golang-samples`\n GitHub repository in the top-level `vertexai` directory:\n\n [github.com/GoogleCloudPlatform/golang-samples](https://github.com/GoogleCloudPlatform/golang-samples/)\n \\\u003e\n [vertexai](https://github.com/GoogleCloudPlatform/golang-samples/tree/main/vertexai)\n- Package\n [**cloud.google.com/go/aiplatform**](https://pkg.go.dev/cloud.google.com/go/aiplatform)\n\n Samples for using this package are available, in the `golang-samples`\n GitHub repository in the top-level `aiplatform` directory:\n\n [github.com/GoogleCloudPlatform/golang-samples](https://github.com/GoogleCloudPlatform/golang-samples/)\n \\\u003e\n [aiplatform](https://github.com/GoogleCloudPlatform/golang-samples/tree/main/aiplatform)\n\n### Client library documentation\n\nFor more information about the library, see the Vertex AI\nclient library for Go documentation:\n\n- Package\n [**cloud.google.com/go/vertexai**](https://pkg.go.dev/cloud.google.com/go/vertexai)\n (**recommended**)\n\n - Vertex AI `cloud.google.com/go/vertexai` [API reference](/go/docs/reference/cloud.google.com/go/vertexai/latest)\n- Package\n [**cloud.google.com/go/aiplatform**](https://pkg.go.dev/cloud.google.com/go/aiplatform)\n\n - Vertex AI `cloud.google.com/go/aiplatform` v1 [API reference](/go/docs/reference/cloud.google.com/go/aiplatform/latest/apiv1)\n - Vertex AI `cloud.google.com/go/aiplatform` v1beta1 [API reference](/go/docs/reference/cloud.google.com/go/aiplatform/latest/apiv1beta1)"]]