Skip to main content

How to integrate and use Google VertexAI models?

Quentin avatar
Written by Quentin
Updated over 6 months ago

The following is the instruction on the steps of how to use Google VertexAI models on EvalsOne/ConsoleX.

Obtain Service Account Key

To use Google VertexAI, you need to utilize a service account created in your project. Follow these steps to generate and download the Json service account key:

  1. Log in to the Google Cloud Console.

  2. Select your project.

  3. Navigate to “IAM & Admin” -> “Service Accounts”.

  4. Click “Create Service Account” and fill in the required details.

  5. Under the “Keys” tab, click “Add Key” and select “JSON” format to download.

Generate Base64 Encoded API Key

Below is the script to encode the service account key. You can use it to create a .py file and run it. Before running, ensure you have correctly set the path to your service account key (if the script and key are in the same folder, you can use just the file name).

import base64
import json

def encode_credentials(file_path):
try:
with open(file_path, 'r') as file:
vertex_credentials = json.load(file)
# Load and encode VertexAI credential
credentials_str = json.dumps(vertex_credentials)
encoded_credentials = base64.urlsafe_b64encode(credentials_str.encode('utf-8')).decode('utf-8')
return encoded_credentials
except FileNotFoundError:
print(f"Error: The file at {file_path} was not found.")
return False
except json.JSONDecodeError:
print("Error: Failed to decode JSON from the file.")
return False

# Generate the encoded credential for usage, make sure to set up the path to your service account key before execution
encoded_credentials = encode_credentials('path-to-your-service-account-key.json')
print(encoded_credentials)

Add Google VertexAI Key on EvalsOne/ConsoleX

Navigate to Integration management page on EvalsOne, add "Create Private Integration" link on top-right area of the page, and fill in the following information:

  1. Project id:Your project ID on Google cloud

  2. Location:The region to process the request

  3. Encoded key:Enter the Base64 encoded API key generated from the script.

Security

Your private information provided on ConsoleX is securely encrypted. If you have security concerns, you can delete or deactivate your keys at any time.

Additional Resources

Did this answer your question?