> For the complete documentation index, see [llms.txt](https://ai2sql.gitbook.io/ai2sql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai2sql.gitbook.io/ai2sql/9.-database-connectors/9.4.-google-bigquery-setup-and-service-account-key-creation.md).

# 9.4. Google BigQuery Setup and Service Account Key Creation

### Introduction

Welcome to our GitBook on setting up Google BigQuery and creating a service account key. This guide is designed to help you get started with BigQuery, Google's fully-managed, petabyte-scale, and cost-effective cloud data warehouse that lets you run super-fast SQL-like queries on your data.

The guide is organized into several sections. Each section contains a specific step in the process of setting up BigQuery and creating a service account key.

### Table of Contents

1. Introduction to Google BigQuery
2. Setting Up Google BigQuery
3. Creating a Google Cloud Service Account Key

### 1. Introduction to Google BigQuery

Google BigQuery is a web service from Google that is used for handling and analyzing big data. It's part of the Google Cloud Platform. BigQuery works with Google's infrastructure, allowing you to execute SQL-like queries on multiple datasets. Its primary features include a columnar storage, data compression, and built-in machine learning capabilities.

### 2. Setting Up Google BigQuery

#### 2.1 Google Cloud Console

1. Navigate to [Google Cloud Console](https://console.cloud.google.com/).
2. If you haven't already, sign in to your Google account. If you don't have one, you'll need to create a Google Account.
3. Once logged in, you'll need to create a new Project.
   * Click on the project drop-down and select `New Project`.
   * In the new window, give your project a name, then click `Create`.

#### 2.2 Enable BigQuery API

1. After your project is created, you need to enable the BigQuery API.
2. In the Google Cloud Console, go to the `APIs & Services` -> `Library`.
3. In the `Library`, search for `BigQuery API` and click on the result.
4. In the BigQuery API page, click `Enable` to enable the API for your project.

### 3. Creating a Google Cloud Service Account Key

#### 3.1 Creating a Service Account

1. In the Google Cloud Console, go to `IAM & Admin` -> `Service Accounts`.
2. Click `Create Service Account`.
3. In the `Service account name` field, enter a name. The Google Cloud Console fills in the `Service account ID` field based on this name.
4. In the `Service account description` field, enter a description.
5. Click `Create`.

#### 3.2 Granting Permissions to the Service Account

1. On the `Service account permissions` page, select the `Role` drop-down list.
2. In the role list, select `BigQuery` -> `BigQuery Admin` to grant full access to BigQuery resources.
3. Click `Continue`.

#### 3.3 Creating a JSON key for the Service Account

1. On the `Grant users access to this service account` page, click `Create Key`.
2. In the `Create key` pane, select the `JSON` key type.
3. Click `Create`. A JSON key file is downloaded to your system.

**Note:** Securely store the JSON key file. If someone obtains your key file, they could use it to access and consume your BigQuery resources.

#### 3.4 Adding JSON Key to AI2SQL

1. In the setup form, you will be asked to provide your JSON key.
2. Open the JSON key file you downloaded from the Google Cloud Console in a text editor. Copy all of its content.
3. In the next field, labeled 'Dataset ID', enter the specific Dataset ID that you want to use.
4. Paste the copied content in the `Service Account Key` field in AI2SQL.
5. Click `Add Connector`.

<div align="left"><figure><img src="/files/zaY80phmgUv95VsoViwl" alt="" width="375"><figcaption></figcaption></figure></div>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ai2sql.gitbook.io/ai2sql/9.-database-connectors/9.4.-google-bigquery-setup-and-service-account-key-creation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
