Client libraries provide an optimized developer experience for calling the AI Platform (Unified) API. The client libraries use each supported language's natural conventions and reduces boilerplate code that you have to write. The following guide explains how to install them.
Before you begin
- 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 AI Platform (Unified) API.
-
Create a service account:
-
In the Cloud Console, go to the Create service account page.
Go to Create service account - Select a project.
-
In the Service account name field, enter a name. The 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
. - Click Create.
-
Click the Select a role field.
Under Quick access, click Basic, then click Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Cloud Console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.
Client libraries
AI Platform provides client libraries for the following languages. Select the language that you want to use.
Java
If you are using Maven
with
BOM,
add the following to your pom.xml
file:
<dependencies> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-aiplatform</artifactId> <version>0.4.0</version> </dependency>
If you are using Maven without BOM, add the following to your dependencies:
<dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-aiplatform</artifactId> <version>0.4.0</version> </dependency>
If you are using Gradel, add the following to your dependencies:
compile 'com.google.cloud:google-cloud-aiplatform:0.4.0'
If you are using sbt, add the following to your dependencies:
libraryDependencies += "com.google.cloud" % "google-cloud-aiplatform" % "0.4.0"
Try code samples
To view or get individual code samples, go to the java-aiplatform GitHub repository.
Client library documentation
For more information, view the Google AI Platform Client for Java documentation.
Node.js
Before installing the library, prepare your environment for Node.js development.
Run the following command in your environment to install the client library:
npm install @google-cloud/aiplatform
Client library documentation
For more information, view the AI Platform: Node.js Client documentation.
Python
AI Platform (Unified) SDK
The Python client library for AI Platform (Unified) is now called the
AI Platform (Unified) SDK. With the release of version 0.7
(Preview),
the AI Platform (Unified) SDK provides two levels of support. The high-level
aiplatform
library is designed to simplify common
data science workflows by using wrapper classes and opinionated defaults.
The lower-level aiplatform.gapic
library remains
available for those times when you need more flexibility or control, or
for those methods that are not supported by the AI Platform (Unified) SDK.
When you install the AI Platform (Unified) SDK, you can use both levels of
support. If you mix aiplatform
and aiplatform.gapic
calls in the same
workflow, be aware that the two approaches use different initialization
procedures; you must initialize for each one separately.
Before you install
Before you install the AI Platform (Unified) SDK, we recommend creating an
isolated Python environment for each project. Activate a venv
environment or use another
method to create an isolated Python environment.
Learn more about setting up a Python development environment to work with Google Cloud.
Another option is to create an AI Platform Notebooks instance for this project. If you are working in a notebook, install the AI Platform (Unified) SDK on your notebook instance or environment.
Install the AI Platform (Unified) SDK
Run the following command in your virtual environment to install the AI Platform (Unified) SDK:
YOUR_ENVIRONMENT/bin/pip install google-cloud-aiplatform
Try code samples
To view or get individual code samples, go to the python-aiplatform GitHub repository.
Client library documentation
For more information, view the Python Client for Cloud AI Platform documentation.