# Create Google Cloud Vertex AI API Key

### Step 1: Create new project

Go to <https://console.cloud.google.com/projectcreate>, enter project name and click **Create.**

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FHCxceuxHzk1sSFtaueoN%2Fvertex1.jpg?alt=media&#x26;token=630e9921-6299-4394-8684-6b9b78dd3c8e" alt=""><figcaption></figcaption></figure>

### Step 2: Create new service account

Go to [https://console.cloud.google.com/iam-admin/serviceaccounts](https://console.cloud.google.com/iam-admin/serviceaccounts?authuser=1), select the project just created in [#step-1-create-new-project](#step-1-create-new-project "mention").

Click **Create Service Account**.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FE62tS5Llb5sLinhLsBeh%2Fvertex22.jpg?alt=media&#x26;token=f251b80d-4a6c-4f41-8601-a6865bffe163" alt=""><figcaption></figcaption></figure>

Enter name, description for service account and click **Create and Continue**.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FdPMuUBfY4AlYwCXhNcEd%2Fvertex31.jpg?alt=media&#x26;token=8701f2dc-109b-4ea2-a62f-c8b6c1036c63" alt=""><figcaption></figcaption></figure>

Click **Select a role** and search for **Vertex AI Service Agent**, then select it.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FIYBblxDQ3vWASox52Ev8%2Fvertex33.jpg?alt=media&#x26;token=30068062-deb2-4fe5-a08e-7c22609a73cd" alt=""><figcaption></figcaption></figure>

Click **Continue**.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2F9LFVNP1gYZDrN3AhLZ2n%2Fvertex44.jpg?alt=media&#x26;token=84d74f2b-8ac7-4781-bb61-4950abd9eab8" alt=""><figcaption></figcaption></figure>

Click **Done**.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FBAFt3fzzfY6HPk7ucmC3%2Fvertex5.jpg?alt=media&#x26;token=93592166-22c2-4eb2-89f8-29ad577b78cc" alt=""><figcaption></figcaption></figure>

### Step 3: Generate new key

Click on the service account just created, then select **Keys** tab.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FGy2BNQkjc6Ug6Cmne8qT%2Fvertex7.jpg?alt=media&#x26;token=4c23c0ea-a94b-4a73-88cd-66c5cfb95baf" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FRl1sbmsE8mN6bNTPsfDO%2Fvertex8.jpg?alt=media&#x26;token=49b2c871-aaf6-44eb-a029-eb973eb5919f" alt=""><figcaption></figcaption></figure>

Click **Add Key** and select **Create new key**.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FiTRmnSjjHVxa4BWEm1Vq%2Fvertex9.jpg?alt=media&#x26;token=4a60c8d7-552f-423a-a75f-da6270bf5239" alt=""><figcaption></figcaption></figure>

Select **JSON** and click **Create**.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FfIvrolHr7GUYZwFxJdHb%2Fvertex10.jpg?alt=media&#x26;token=d6f40d9e-0004-4699-a145-8b25362ab5d7" alt=""><figcaption></figcaption></figure>

A JSON file will be downloaded into your machine. Keep that file secret. Open that file and copy whole file content.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FnJCGUXVGB9FVSPfBSJBF%2Fvertex11.jpg?alt=media&#x26;token=79fd15c9-092f-47c0-9c12-509fc1b333e5" alt=""><figcaption></figcaption></figure>

Key file content looks like below:

```
{
  "type": "service_account",
  "project_id": "mindmac-300128",
  "private_key_id": "12efb3bcc7u7dbf111842f27415d37454c6d6fa012",
  "private_key": "-----BEGIN PRIVATE KEY-----\nMIIE...8XI3A=\n-----END PRIVATE KEY-----\n",
  "client_email": "mindmac-service-account@mindmac-300128.iam.gserviceaccount.com",
  "client_id": "208453549200948148846",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/mindmac-service-account%40mindmac-300128.iam.gserviceaccount.com",
  "universe_domain": "googleapis.com"
}
```

### Step 4: Enable Vertex AI API

Go to <https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com>, select the project just created and click **Enable** to activate Vertex AI API.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2Fot5sh1kvP5J5q5vNANcA%2Fvertex12.jpg?alt=media&#x26;token=cc4b4074-3cb1-497b-85a9-6c373fef218e" alt=""><figcaption></figcaption></figure>

### Step 5: Grab information to construct API URL

Go to <https://console.cloud.google.com/vertex-ai>, select project just created and take note region name.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2FbrcStPTqvzGejicesgOl%2Fvertex13.jpg?alt=media&#x26;token=b91dcbbe-57dc-4566-916f-3cc2e34470e1" alt=""><figcaption></figcaption></figure>

Go to <https://console.cloud.google.com/welcome>, select project just created and copy the project ID.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2F1WWXa43C7ttonXBPjJ5Q%2Fvertex14.jpg?alt=media&#x26;token=74505a22-7681-4072-989b-6268f9888763" alt=""><figcaption></figcaption></figure>

Vertex AI API URL has format:&#x20;

```
https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models
```

* LOCATION is the region name above, for example **us-central1**
* PROJECT\_ID is the ID of the project above

In this case it should be:

```
https://us-central1-aiplatform.googleapis.com/v1/projects/mindmac-300128/locations/us-central1/publishers/google/models
```

***

### Add Google Vertex AI key

Go to **MindMac** -> **Settings...** -> **Account** or press <mark style="color:purple;">**⌘ + ,**</mark> to open Account Setting.

<figure><img src="https://2130568151-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxe3N3qPZEhbHGWOpdQfl%2Fuploads%2Fb9evfD9C0h2BgVM7IkBK%2Faddapikey3.jpg?alt=media&#x26;token=0f273c56-9204-440c-acb4-97a999b4b02d" alt=""><figcaption></figcaption></figure>

Select **Vertex AI** provider, enter name and your custom URL from [#step-5-grab-information-to-construct-api-url](#step-5-grab-information-to-construct-api-url "mention"), paste Service Account key content from [#step-2-create-new-service-account](#step-2-create-new-service-account "mention") and click **Save** to finish.
