> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/g/google-big-query-ai.md).

# Google Big Query AI

This adapter reads a BigQuery table with one AI model per row and adds the rows to the OctoXLabs inventory as ai models. Columns named like the canonical OctoXLabs fields map automatically. Other columns are kept as raw data.

## Use cases

* List AI models loaded from your BigQuery table.
* Review models by workspace or version using the ModelName, ModelVersion and WorkspaceName columns.

## Before you begin

### Network

| Source              | Destination                             | Port | Protocol |
| ------------------- | --------------------------------------- | ---- | -------- |
| OctoXLabs connector | Google BigQuery API (host Not verified) | 443  | HTTPS    |

### Required permissions

| Scope or role                                      | Permission | Needed for                                                    |
| -------------------------------------------------- | ---------- | ------------------------------------------------------------- |
| BigQuery Data Viewer (`roles/bigquery.dataViewer`) | Read       | Reading the table schema and rows on the table or its dataset |

The adapter does not run query jobs. The BigQuery API must be enabled in the project.

## Create credentials in Google Cloud

{% stepper %}
{% step %}

### Create a service account

Open the [Service accounts page](https://console.cloud.google.com/iam-admin/serviceaccounts) of a Google Cloud project and create a service account.
{% endstep %}

{% step %}

### Enable the BigQuery API

In the project, go to **APIs & Services** > **Library** and enable the **BigQuery API**.
{% endstep %}

{% step %}

### Grant the role

Give the service account the **BigQuery Data Viewer** (`roles/bigquery.dataViewer`) role on the table or its dataset.
{% endstep %}

{% step %}

### Create a key

Open the service account, go to the **Keys** tab, select **Add key** > **Create new key**, choose **JSON**, and upload the downloaded file in OctoXLabs.
{% endstep %}
{% endstepper %}

{% hint style="danger" %}
The key file holds the only copy of the private key. Store it securely. If you lose it, create a new key.
{% endhint %}

## Connection parameters

| Parameter                | Required | Type        | Default    | Description                                                                                                                          |
| ------------------------ | -------- | ----------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Service Account Email    | Yes      | String      | None       | Email of the Google Cloud service account. It must match `client_email` in the key file.                                             |
| Service Account Key File | Yes      | File (JSON) | None       | JSON key file of the service account.                                                                                                |
| Project ID               | Yes      | String      | None       | ID of the Google Cloud project that holds the dataset.                                                                               |
| Dataset ID               | Yes      | String      | None       | ID of the BigQuery dataset that holds the table.                                                                                     |
| Table ID                 | Yes      | String      | None       | ID of the table with one AI model per row. Only tables and table snapshots can be read. Views and external tables are not supported. |
| Primary Key Field        | No       | String      | PrimaryKey | Column holding the unique identifier per row.                                                                                        |
| Https Proxy              | No       | String      | None       | Proxy URL.                                                                                                                           |
| Timeout                  | No       | Integer     | 30         | Seconds to wait for API responses.                                                                                                   |

## Troubleshooting

| Error message | Cause                                     | Fix                                                                                                      |
| ------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Not verified  | No error text could be confirmed in code. | Run a connection test. Check the key file, the role on the table and the Project, Dataset and Table IDs. |

## Change history

{% hint style="info" %}
Available starting from version 6.9.1.
{% endhint %}
