Create BYOM Connection on Google Vertex AI

Picture of Rohit Kamble

Rohit Kamble

Updated on March 6, 2024

This document guides you through setting up a Google Cloud Platform (GCP) environment, connecting to Vertex AI, and consuming a BISON model using the REST API.

Prerequisites:

  1. A Google account

  2. A new Google Cloud Platform (GCP) subscription (https://cloud.google.com/)

  3. A service account with the necessary permissions

Step 1: Create a Google Cloud Project

  1. Go to the Google Cloud Console.

  2. Click on “Create Project”.

  3. Enter a project name and click on “Create.”

Step 2: Enable the Vertex AI API

  1. Search for Vertex AI from the global search bar and activate the API if it’s your first time using it.

  2. GPTfy will use foundation models, so no custom model deployment is needed.

Step 3: View Details

  1. Navigate to the next option by clicking on View Details.

Step 4: Test Vertex AI on the Playground (Optional)

  1. Click on Open Prompt Design

  2. Ask a question on the next screen. If you receive answers, then the model setup is complete.

Step 5: Create a Service Account

  1. Go to the IAM & Admin page.

  2. Click on “Create Service Account”.

  3. Enter a service account name and click on “Create.”

  4. Grant the service account the following roles:
    1. Vertex AI Service Agent (roles/aiplatform.serviceAgent)
    2. Cloud Storage Object Creator (roles/storage.objectCreator)

Step 6: Download the Service Account Key

  1. Click on the service account you created.

  2. Click on the “Keys” tab.

  3. Click on “Add Key” and select “JSON”.

  4. Download the JSON key file. (KEEP IT SECURE)

Step 7: Consume the Model through REST API (Optional)

  1. Use the following cURL command to consume the model:
				
					API_ENDPOINT="us-central1-aiplatform.googleapis.com"
PROJECT_ID="gptfy-ai-playground"
MODEL_ID="text-bison-32x"
LOCATION_ID="us-central1"

curl \
-X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/publishers/google/models/${MODEL_ID}:predict" \
-d @request.json
				
			

Replace {PROJECT_ID}, {LOCATION_ID}, {MODEL_ID}, and {API_ENDPOINT} with the appropriate values. Replace $(gcloud auth print-access-token) with the access token obtained from the service account key.

Additional Notes

  1. The service account key should be stored securely.

  2. The model URI must be a Google Cloud Storage URI.

  3. The model must be in the same region as the endpoint.

  4. The REST API endpoint URL may vary depending on the region.