Article

    How to Generate a Google Gemini API Key (Service Account Key)

    2 min read
    Last updated 4 months ago

    These steps will create a Google Cloud service account with the right permissions and give you a JSON key file to share securely.

    1. Sign in to Google Cloud Console

    1. Go to: https://console.cloud.google.com

    2. Make sure you’re in the correct Google Cloud project that is tied to your Google Workspace / Gemini instance.

    2. Enable the Vertex AI API (if not already enabled)

    1. In the top search bar, type "Vertex AI API".

    2. Click Enable.

      • If it says “API enabled,” you can skip this step.

    3. Create a Service Account

    1. In the left menu, go to IAM & Admin > Service Accounts.

    2. Click + CREATE SERVICE ACCOUNT.

    3. Fill in:

      • Service account name: gemini-api-access (or similar)

      • Description: "Access for Gemini API calls"

    4. Click Create and Continue.

    4. Grant the Required Role

    1. Under Grant this service account access, click + Select a role.

    2. In the search box, type:

      Vertex AI User
      
      

      and select it.

    3. (Optional but safer) If you want to scope it down further, you can create a custom role that only has:

      aiplatform.endpoints.predict
      
      

      but "Vertex AI User" is the standard.

    4. Click Continue, then Done.

    5. Create a JSON Key

    1. In the Service Accounts list, find your new account.

    2. Click the three dots () on the right > Manage keys.

    3. Under Keys, click Add key > Create new key.

    4. Choose JSON and click Create.

      • This downloads a file ending in .json.

      • This file is your API key.

    6. Send the Key Securely

    • Do not email the file as an attachment.

    • Instead:

      • Upload it to a secure company file-share (e.g., Google Drive with restricted access).

      • Or use a secure password manager’s sharing feature.

    • Notify us when it’s shared.