Google Vertex AI Models
Here are the steps for using Google Vertex AI models on ConsoleX.
Getting Service Account Key
To use Google Vertex AI, you need to use a service account created in your project. Follow these steps to generate and download a JSON format service account key:
- Log in to Google Cloud Console.
- Select your project.
- Navigate to "IAM & Admin" -> "Service Accounts".
- Click "Create Service Account" and fill in the required information.
- Under the "Keys" tab, click "Add Key" and select "JSON" format for download.
Generate Base64 Encoded API Key
Here's a script for encoding the service account key. You can create a .py
file and run it. Before running, make sure to set the correct path to the service account key (if the script and key are in the same folder, you can use the filename directly).
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 Vertex AI credentials
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: File not found at path {file_path}.")
return False
except json.JSONDecodeError:
print("Error: Unable to decode JSON from file.")
return False
# Generate encoded credentials for use, make sure to set the path to your service account key before execution
encoded_credentials = encode_credentials('path-to-your-service-account-key.json')
print(encoded_credentials)
Adding Google Vertex AI Key on ConsoleX
Navigate to EvalsOne's integration management page, click the "Create Private Integration" link in the top right corner of the page, and fill in the following information:
- Project ID: Your Google Cloud project ID.
- Location: The region where requests will be processed.
- Encoded Key: Enter the Base64 encoded API key generated through the script.
Security
The private information you provide on ConsoleX is securely encrypted. If you have security concerns, you can delete or deactivate your key at any time.
References
- Using Generative AI with Vertex AI: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/overview
- About Service Accounts: https://cloud.google.com/iam/docs/service-account-overview