# Set up Gemini API Keys for Discourse AI

**URL:** https://meta.discourse.org/t/set-up-gemini-api-keys-for-discourse-ai/320688
**Category:** Integrations
**Tags:** how-to, ai
**Created:** [August 8, 2024, 7:46am UTC](https://meta.discourse.org/t/set-up-gemini-api-keys-for-discourse-ai/320688 "2024-08-08T07:46:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [August 8, 2024, 7:46am UTC](https://meta.discourse.org/t/set-up-gemini-api-keys-for-discourse-ai/320688/1 "2024-08-08T07:46:20Z")

</div>

# How to Set Up Gemini API Keys for Discourse AI

## Introduction

This topic covers how to set up your Google Gemini API key with an existing Google Cloud account project. Gemini is not a free service, and therefore, you will need to ensure you have billing configured in your Google Cloud admin.

There is some important information with links in the [Gemini Developer studio](https://aistudio.google.com/) key generating page about this:

 ![The image is a screenshot of a text document that appears to be instructions for using the Google API platform. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/6/1/4/61423e3471367450d097d5baed34d0231d6ea739.png)

Ok, let’s get started!

> ☝ **NOTE** : Admin level access to Google Cloud and your Discourse forum are required.

* * *

## Step 1: Setting up a Google Cloud Project

Setting up a Gemini API key properly requires you to have admin access to your Google Cloud account, and to create a billing project there you can use for your Gemini API key usage.

You may create your key in the Gemini Studio and connect to your Google Cloud, but it is somewhat easier to do it all from the Google Cloud console so you don’t have to go back and forth.

Go to [Google Cloud admin for API](https://console.cloud.google.com/apis/credentials) for your organization, and make sure you are in the parent organization (you can see it in the field at top next to the Google Cloud logo).

 ![This image displays a computer screen showing a Google cloud project page with sections for resource selection and new project creation. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/1/4/a/14a3bcd1a475c66c83a74c3cfe415feeaa9a0ebe.png)

You will have to create a project for your Gemini key if you haven’t got one already that you want to use (note the link to select or create a new project is at top left of page).

 ![The image displays a screenshot from a Google Chrome browser window showing a Google Cloud Platform webpage with a search bar and a list of API services. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/b/0/b/b0b3958294b31ae4d04c87df188461250082612d.jpeg)

For a new project, complete the create new project page (make sure your organization is selected in the appropriate drop-down field).

 ![The image shows a computer screen displaying a dialogue box with a prompt for new project creation. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/7/c/4/7c48b3057b521f63909b6e2ce213d316ad2d5dc4.png)

For managing billing for your project, you will need to set up a billing account for the project in [Google Cloud billing](https://console.cloud.google.com/billing/projects), assuming you have billing configured for your organization. You (or your billing account manager) should be able to do this later after the key is created. Note that there are quotas on projects and billing projects depending on your organization’s Google Cloud account. To enable billing on your project, go to the Billing tab in the Google Cloud navigation menu and link a billing account (see the “Manage Billing Accounts” link) and enable billing for the project from the [billing projects page](https://console.cloud.google.com/billing/projects).

* * *

## Step 2: Create a Gemini API Key

> ⚠ **IMPORTANT!** Remember to use your API keys securely. Please carefully read [Keep your API key secure](https://ai.google.dev/gemini-api/docs/api-key#security) and [Best practices for securely using API keys](https://support.google.com/googleapi/answer/6310037) before proceeding.

Now you are ready to create an API key in the project. Go to the credentials for that project, click the “+ create credentials” link at the top, and select “API key” from the drop-down options.

 ![The image is a screenshot of a computer interface for a Google account settings page, showing a menu with various options related to API services. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/4/8/a/48a3d7aff739c933815bc197586c3bfb364e99f1.png)

A new API key will be created for you. Copy and secure it in a safe place like a password vault application. Do not share keys. This is the key you will need to enter into your Discourse AI settings.

 ![The image shows a dialog box with a message for an API key. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/6/0/3/60319530108169db96ec749bcf7cf6d180134274.jpeg)

The key should now be listed in your API keys. Click on it to edit the API key

 ![The image displays a computer screen with Google Cloud Platform services, showing a Google API Console settings page with various options and a note about OAuth consent. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/b/0/d/b0d62d9e59dde0ccca2e1cb04014da33dc970c5c.png)

Give the key an appropriate name, and then go down to the API Restrictions section and select “Restrict key”, then choose “Generative Language API”.

 ![Image of a computer screen with a Google Cloud API key dialog open. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/8/5/7/857aa5072bd34329855ee7b57fb25fbbf35eefff.png)

Save your updated key. Click the “Show key” link for your new key and copy it.

 ![The image is a screenshot of a Google Cloud Platform (GCP) dashboard, showing the API & Services section with the API Gateway, API Management, and API Keys pages. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/9/e/9/9e9291e3be31ae88e203c30e771a8482932b1f11.png)

* * *

## Step 3: Configure Gemini in Discourse AI Settings

Discourse AI now uses a centralized **Credentials** system for managing API keys. Instead of pasting your key directly into each LLM configuration, you first create a credential and then select it when configuring your Gemini model.

### Step 3a: Create a Credential

Go to `Admin > Plugins > AI > Credentials` and click **New Credential**. Give it a descriptive name (e.g., “Gemini API Key”) and paste the API key you copied from Google Cloud. Save the credential.

> 💡 **Tip** : You can also create a credential inline — when adding a new LLM in the next step, click the **+** button next to the credential selector to create one on the fly.

### Step 3b: Add a Gemini LLM

Now go to `Admin > Plugins > AI > LLMs`. Click **Add** and select one of the preconfigured Gemini models (e.g., Gemini 3 Flash or Gemini 3 Pro). The model name, endpoint URL, and other settings will be pre-filled for you. Use the **Credential** dropdown to select the credential you created in the previous step, then save.

> ℹ **Note** : The same credential can be reused across multiple LLM configurations, so you only need to enter your Gemini API key once.

* * *

## Step 4: Tracking Gemini API Key Usage

You can track your Gemini API key usage from your Google Cloud dashboard in billing under “Manage Billing Account”

 ![image](https://global.discourse-cdn.com/meta/original/4X/a/c/7/ac7438948b6655cbca6c339e8a835deada6d4e7f.png)

And then select your specific project from the billing project list, and it will bring up the billing report where you can specify the project(s) and various other details you want to use to track your API key projects (you can track other Google API keys attached to your Google Cloud account here as well, for example, if you have [Google Custom Search API and Programmable Search Engine](https://meta.discourse.org/t/google-search-for-discourse-ai-programmable-search-engine-and-custom-search-api/307107) configured).

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/3/2/132a522cc626847222f515ce5f139c2985bba4e9.png)

* * *

## Links

- [Google Cloud Console](https://cloud.google.com/cloud-console)
- [Gemini API Documentation](https://ai.google.dev/gemini-api/docs/api-key)
- [Discourse AI Documentation](https://meta.discourse.org/t/discourse-ai/259214)
- [Google Custom Search API for Discourse AI](https://meta.discourse.org/t/google-search-for-discourse-ai-programmable-search-engine-and-custom-search-api/307107)
- [Best practices for securely using API keys](https://support.google.com/googleapi/answer/6310037)
- [How to Enable AI Bot](https://meta.discourse.org/t/enable-ai-bot/266012)
- [Set up Discourse AI Summarization](https://meta.discourse.org/t/discourse-ai-summarization/262711)
- [Google AI Pricing](https://ai.google.dev/pricing)

> Last edited by @Lilly 2024-08-08T08:14:48Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![m\_terenui](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/m_terenui/32/537133_2.png) [@m\_terenui](https://meta.discourse.org/u/m_terenui)
#### Post date: [July 4, 2026, 6:14pm UTC](https://meta.discourse.org/t/set-up-gemini-api-keys-for-discourse-ai/320688/2 "2026-07-04T18:14:14Z")

</div>

Hey ! Good Afternoon,

Thanks for the tuto, I am trying to set it up but it seems Google has recently changed its security and since June it is no longer possible to create Gemini API keys unless we create service accounts. I also read that all previously created keys will stop working as from September if not migrated to service accounts keys. I am still trying to figure things out but seems quite complex… Any change to be considered by Discourse platform or would it work the same way as before ?

What key should we add in discourse the one of the API or the service account key ? Anyone has went through the updates already ?

Thanks a lot for your help !  
Cheers,  
Terenui

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [August 6, 2026, 2:03am UTC](https://meta.discourse.org/t/set-up-gemini-api-keys-for-discourse-ai/320688/3 "2026-08-06T02:03:34Z")

</div>

Hi @m_terenui

i have documented the Google Cloud service account → Gemini API key configuration steps here:

> **[Setting up a Gemini api key on a Google Cloud service account](https://disco-docs.com/t/setting-up-a-gemini-api-key-on-a-google-cloud-service-account/423?u=lilly)**
>
> How to set up a Gemini api key on a Google Cloud service account Step 1: set up the service account go to your Google Cloud IAM and admin page and select +create service account at the top menu: follow the prompts and fill out the info: ...

i will suggest an edit to the topic OP when i have more time.
