> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elementum.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Gemini Setup

> Configure Google Gemini as your AI provider for language model services

## Overview

Google Gemini provides language models through Google Cloud's Vertex AI platform, including Gemini 2.5 Pro, Gemini 2.5 Flash, and Gemini 1.5 Pro. This guide walks you through setting up Google Gemini as an AI Provider in Elementum.

<Info>
  **Prerequisites**: You'll need a Google Cloud account with billing enabled and access to Vertex AI APIs.
</Info>

## Step 1: Set Up Google Cloud Project

### Create or Select a Project

1. **Access Google Cloud Console**

   * Go to [console.cloud.google.com](https://console.cloud.google.com)
   * Sign in with your Google account

2. **Create a New Project** (or select an existing one)

   * Click on the project selector at the top of the page
   * Click **New Project**
   * Enter a project name (e.g., "Elementum AI Integration")
   * Select your billing account
   * Click **Create**

3. **Enable Billing**
   * Ensure your project has billing enabled
   * Navigate to **Billing** in the left sidebar
   * Link a billing account if not already configured

### Enable Required APIs

Enable the following APIs for Vertex AI access:

1. In the Google Cloud Console, go to **APIs & Services** → **Library**
2. Search for **Vertex AI API** and click **Enable** — this may take a few minutes to complete
3. Search for **Cloud Resource Manager API** and click **Enable** — this is required for project access

## Step 2: Create Service Account

### Generate Service Account

<Steps>
  <Step title="Navigate to IAM & Admin">
    In the Google Cloud Console, go to **IAM & Admin** → **Service Accounts**
  </Step>

  <Step title="Create Service Account">
    Click **Create Service Account**

    **Service Account Name**: Enter a descriptive name (e.g., "elementum-ai-service")

    **Service Account ID**: Will be auto-generated

    **Description**: Optional description for the service account
  </Step>

  <Step title="Grant Permissions">
    Assign the following roles to your service account:

    **Required Role**:

    * **Vertex AI User** (`roles/aiplatform.user`) — Access to Vertex AI models including Gemini

    **Optional Roles** (for advanced features):

    * **BigQuery User** — If integrating with BigQuery
    * **Storage Object Viewer** — If accessing Cloud Storage
  </Step>

  <Step title="Complete Creation">
    Click **Continue** and then **Done** to create the service account
  </Step>
</Steps>

### Generate Service Account Key

<Steps>
  <Step title="Access Service Account">
    In the Service Accounts list, click on your newly created service account
  </Step>

  <Step title="Create Key">
    Go to the **Keys** tab

    Click **Add Key** → **Create new key**
  </Step>

  <Step title="Select Key Type">
    Choose **JSON** as the key type

    Click **Create**
  </Step>

  <Step title="Download Key File">
    The JSON key file will be automatically downloaded

    **Critical**: Copy and store this file securely — it contains credentials for your service account and cannot be downloaded again
  </Step>
</Steps>

<Warning>
  Never share your service account key file or commit it to version control. Store it in a secure location like a password manager.
</Warning>

## Step 3: Configure Gemini in Elementum

### Add the Provider

1. In Elementum, go to **Organization Settings** and select the **Providers** tab
2. Click **+ Provider** and select **Gemini** from the provider options
3. Configure the provider settings:

<Tabs>
  <Tab title="Basic Configuration">
    **Provider Name**: Enter a descriptive name (e.g., "Google Gemini Production")

    **Location**: Select your Google Cloud region (e.g., "us-central1")

    **Project ID**: Enter your Google Cloud project ID

    **CloudLink**: Select which CloudLinks can access models from this provider. Leave as "All CloudLinks" unless you need to restrict access.

    <Note>
      AI services do not support CloudLinks configured with **API** as the connection type. Only CloudLinks connected to a supported data warehouse (Snowflake, BigQuery, or Databricks) can be associated with this provider.
    </Note>
  </Tab>

  <Tab title="Service Account">
    **Service Account Credentials**: Upload or paste your JSON key file content

    The JSON should look like this:

    ```json theme={null}
    {
      "type": "service_account",
      "project_id": "your-project-id",
      "private_key_id": "...",
      "private_key": "...",
      "client_email": "elementum-ai-service@your-project.iam.gserviceaccount.com",
      "client_id": "...",
      "auth_uri": "https://accounts.google.com/o/oauth2/auth",
      "token_uri": "https://oauth2.googleapis.com/token"
    }
    ```
  </Tab>
</Tabs>

4. Click **Save** to create the provider. Elementum will automatically validate your credentials — look for a green checkmark indicating a successful connection.

## Step 4: Create your first AI service

With your Gemini provider configured, create an AI Service that uses a Gemini model. See [AI Services](/ai-agents/ai-services) for the full walkthrough, including LLM service configuration, assignment, and failover.

For a side-by-side comparison of the Gemini models available in Elementum—including recommendations for daily tasks vs. complex reasoning—see [AI Models](/ai-agents/ai-models).

<Info>
  **Note**: Embeddings for AI Search are handled exclusively through Snowflake Cortex. Gemini models are used for LLM services only.
</Info>

## Usage Guidelines

### Cost Management

Google Cloud charges for Vertex AI usage. To manage costs:

<Tabs>
  <Tab title="Monitor Usage">
    * Monitor usage in the Google Cloud Console
    * Set up billing alerts for cost control
    * Review and adjust API quotas as needed
    * Regularly review usage patterns
  </Tab>

  <Tab title="Optimize Usage">
    * Choose appropriate models for each task
    * Use Gemini 2.5 Flash for speed-critical applications
    * Cache responses when possible
    * Minimize unnecessary API calls
  </Tab>
</Tabs>

### Best Practices

<Accordion title="Model Selection">
  * Use **Gemini 2.5 Flash** for most general-purpose tasks and customer support
  * Use **Gemini 2.5 Pro** for complex reasoning, advanced analysis, and large responses
  * Use **Gemini 1.5 Pro** for established production workloads requiring reliable performance
</Accordion>

<Accordion title="Prompt Engineering">
  * Be specific and clear in your prompts
  * Use system messages for consistent behavior
  * Provide examples for better results
  * For Gemini 2.5 Pro, structure complex problems step-by-step
</Accordion>

<Accordion title="Performance Optimization">
  * Select Google Cloud regions closest to your users
  * Choose Gemini 2.5 Pro for tasks requiring detailed analysis
  * Use Gemini 2.5 Flash for high-volume, simple tasks
  * Implement retry logic for transient errors
</Accordion>

## Troubleshooting

<Accordion title="Authentication Errors">
  **Symptoms:** Service account authentication failures

  **Common Causes:**

  * Invalid service account key
  * Insufficient permissions
  * Disabled APIs

  **Solutions:**

  1. Verify service account key is valid JSON
  2. Check service account roles and permissions
  3. Ensure required APIs are enabled
  4. Regenerate service account key if needed
</Accordion>

<Accordion title="API Access Issues">
  **Symptoms:** Cannot access Vertex AI APIs

  **Common Causes:**

  * APIs not enabled
  * Billing not configured
  * Regional restrictions

  **Solutions:**

  1. Enable Vertex AI API in Google Cloud Console
  2. Verify billing is enabled and active
  3. Check regional availability of services
  4. Review project quotas and limits
</Accordion>

<Accordion title="Rate Limit Issues">
  **Symptoms:** Requests being throttled or rejected

  **Common Causes:**

  * Exceeding Vertex AI quotas
  * High concurrent usage
  * Regional quota limitations

  **Solutions:**

  1. Implement exponential backoff
  2. Reduce request frequency
  3. Review and adjust quotas in Google Cloud Console
  4. Distribute load across multiple regions
</Accordion>

<Accordion title="Model Unavailable">
  **Symptoms:** Expected models don't appear in service creation

  **Common Causes:**

  * Regional model availability
  * Account access restrictions
  * Model deprecation

  **Solutions:**

  1. Check model availability in your region
  2. Review account access and permissions
  3. Contact Google Cloud support for access issues
  4. Consider alternative models
</Accordion>

## Security Considerations

<Tabs>
  <Tab title="Service Account Security">
    * Regularly rotate service account keys
    * Use IAM roles for fine-grained access control
    * Monitor service account usage for anomalies
    * Enable audit logging for security tracking
  </Tab>

  <Tab title="Data Privacy">
    * Review Google's current data handling and privacy policies
    * Consider data sensitivity when crafting prompts
    * Data is encrypted in transit and at rest
    * Monitor data access patterns
  </Tab>
</Tabs>

## Advanced Configuration

### Multi-Region Setup

For global deployments, consider the following when selecting regions:

* **Region Selection**: Choose regions closest to your users for lower latency
* **Data Residency**: Ensure your region choices meet data residency requirements
* **Failover**: Implement failover strategies across regions for high availability
* **Compliance**: Verify regional compliance with applicable regulations

### Custom Model Access

If you need access to specialized or private models in Vertex AI:

* **Model Registration**: Register custom models in Vertex AI
* **Access Control**: Configure proper IAM permissions for model access
* **Monitoring**: Set up custom monitoring and alerting for model performance

## Next Steps

With Google Gemini configured as your AI Provider:

<CardGroup cols={2}>
  <Card title="Create AI Services" icon="cog" href="/ai-agents/ai-services">
    Set up specific LLM and embedding services for your workflows
  </Card>

  <Card title="Configure Snowflake Cortex" icon="snowflake" href="/ai-agents/snowflake-cortex-setup">
    Set up Snowflake Cortex for AI Search and embeddings
  </Card>

  <Card title="Build Agents" icon="robot" href="/ai-agents/agents-experience">
    Create conversational AI assistants using Gemini models
  </Card>

  <Card title="Use AI Actions" icon="zap" href="/workflows/automation-actions-reference">
    Add AI capabilities to your automation workflows
  </Card>
</CardGroup>
