Vertex AI Translation in Google Distributed Cloud (GDC) air-gapped appliance lets you translate text and documents between supported languages in your applications. After creating a project and requesting developer roles, enable the Vertex AI Translation API in the GDC console to view its status and endpoint. You can then install the Python client library, define environment variables, and use the gdcloud CLI to configure service accounts and authenticate requests. If you are new to Vertex AI, see Learn about translation features.
Create a project
Creating a translation project organizes your Vertex AI Translation resources, which include collaborators, enabled APIs, authentication credentials, and access controls.
To create your project, see Set up a project for Vertex AI. You need your project ID when making API calls.
Request developer permissions
You must have the AI Translation Developer role in your project to access translation services and generate an API token for request authentication and authorization.
Ask your Project IAM Admin to grant the AI Translation Developer
(ai-translation-developer) role to your user or service account
within your project namespace. For information about this role, see
Prepare IAM permissions.
Enable the Vertex AI Translation API
You must enable the Vertex AI Translation pre-trained API for your project. If enabled, you can view the service status and endpoint for the Vertex AI Translation pre-trained API.
Install client libraries
Client libraries are available for the Python programming language. We recommend using these client libraries to make calls to the Vertex AI Translation API because they make it easier to access APIs.
Install the Vertex AI Translation client library and follow these steps to ensure you have the correct version:
Check if the Vertex AI Translation client library is installed and obtain the version number:
pip freeze | grep translationIf the client library is already installed, you obtain an output similar to the following example:
google-cloud-translation==3.8.0The version number you obtain must match the client library at the following endpoint:
https://GDC_URL/.well-known/static/client-librariesReplace
GDC_URLwith the URL of your organization in GDC.If the version numbers don't match, uninstall the client library:
pip uninstall google-cloud-translationIf you uninstalled the Vertex AI Translation client library, you must reinstall it by specifying the filename corresponding to your operating system.
Set your environment variables
After installing the Vertex AI Translation client library, you can interact with the API from a Python script.
If you set up a service account in your project to make authorized API calls programmatically, you can define environment variables in the Python script to access values such as the service account keys when running.
Follow these steps to set required environment variables on a Python script:
Create a Python script.
Add the following code to the Python script:
import os os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "APPLICATION_DEFAULT_CREDENTIALS_FILENAME"Replace
APPLICATION_DEFAULT_CREDENTIALS_FILENAMEwith the name of the JSON file that contains the service account keys you created in the project, such asmy-service-key.json.Save the Python script with a name, such as
translation.py.Run the Python script to set the environment variables:
python SCRIPT_NAMEReplace
SCRIPT_NAMEwith the name you gave to your Python script, such astranslation.py.
Set up authentication
Before you can start using the Vertex AI Translation API, you must authenticate your client credentials and request account access to your project resources. For more information, see Authenticate API requests.