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 key generating page about this:
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 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).
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).
For a new project, complete the create new project page (make sure your organization is selected in the appropriate drop-down field).
For managing billing for your project, you will need to set up a billing account for the project in Google Cloud billing, 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.
Step 2: Create a Gemini API Key
IMPORTANT! Remember to use your API keys securely. Please carefully read Keep your API key secure and Best practices for securely using API keys 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.
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 key should now be listed in your API keys. Click on it to edit the API key
Give the key an appropriate name, and then go down to the API Restrictions section and select “Restrict key”, then choose “Generative Language API”.
Save your updated key. Click the “Show key” link for your new key and copy it.
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”
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 configured).
Links
- Google Cloud Console
- Gemini API Documentation
- Discourse AI Documentation
- Google Custom Search API for Discourse AI
- Best practices for securely using API keys
- How to Enable AI Bot
- Set up Discourse AI Summarization
- Google AI Pricing
Last edited by @Lilly 2024-08-08T08:14:48Z
Check document
Perform check on document:










