> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/lopiv2/invenicum/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Gemini Integration

> Configure Google Gemini AI to enable intelligent inventory features in Invenicum

## Overview

Invenicum integrates with Google's Gemini AI to provide advanced capabilities like automatic product data extraction from URLs and intelligent inventory assistance through the Venibot chatbot.

<Info>
  Gemini integration is **optional** but highly recommended for enhanced productivity and automation features.
</Info>

## Prerequisites

* Active Google account
* Access to Google AI Studio
* Invenicum account with active session

## Step-by-Step Setup

<Steps>
  <Step title="Get Your Gemini API Key">
    1. Visit [Google AI Studio](https://aistudio.google.com/)
    2. Sign in with your Google account
    3. Navigate to **API Keys** section
    4. Click **Create API Key** or **Get API Key**
    5. Copy the generated API key (format: `AIza...`)

    <Warning>
      Keep your API key secure. Never share it publicly or commit it to version control.
    </Warning>
  </Step>

  <Step title="Configure Integration in Invenicum">
    1. Open Invenicum and navigate to **Settings** → **Integrations**
    2. Find the **Google Gemini AI** integration card
    3. Click **Configure** or tap on the card
    4. In the configuration sheet, enter your API key

    <ParamField path="apiKey" type="string" required>
      Your Google Gemini API key from AI Studio. This field is masked for security.
    </ParamField>

    <ParamField path="model" type="string" default="gemini-3-flash-preview">
      The Gemini model to use. Recommended: `gemini-3-flash-preview` for optimal performance.
    </ParamField>
  </Step>

  <Step title="Save and Verify">
    1. Click **Save** to store your configuration
    2. The integration status should change to **Connected** ✓
    3. You'll see a confirmation message

    <Info>
      The API key is stored securely on the backend and never exposed in the client.
    </Info>
  </Step>

  <Step title="Enable AI Features">
    1. Navigate to **Settings** → **General Settings**
    2. Find the **AI Features** toggle
    3. Enable it to activate Gemini-powered features

    <Note>
      The AI toggle will only be available after successfully connecting Gemini integration.
    </Note>
  </Step>
</Steps>

## Available AI Features

Once configured, you can use these Gemini-powered features:

### Magic Assistant (URL Extraction)

Automatically extract product information from URLs:

1. Create or edit an asset
2. Click **AI Magic Assistant**
3. Paste a product URL (Amazon, eBay, etc.)
4. Click **Start Magic**
5. AI will fill fields like name, description, price, and more

<Tip>
  The AI extraction endpoint is `/ai/extract` and can extract custom fields defined in your asset types.
</Tip>

### Venibot Chatbot

Ask questions about your inventory:

* "What's in stock?"
* "Show me active loans"
* "Generate inventory report"

Access Venibot from the dashboard or inventory screens.

## Configuration Files

The Gemini integration is defined in:

**Integration Definition:** `lib/core/utils/constants.dart:25-42`

```dart theme={null}
IntegrationConfig(
  id: 'gemini',
  name: 'Google Gemini AI',
  description: 'Connect with Google\'s Gemini AI',
  fields: [
    ConfigField(
      id: 'apiKey',
      type: ConfigFieldType.text,
      label: 'API Key',
      helperText: 'Get it at https://aistudio.google.com/',
    ),
    ConfigField(
      label: 'Model',
      type: ConfigFieldType.text,
      helperText: 'Default: gemini-3-flash-preview',
    ),
  ],
)
```

**AI Service:** `lib/data/services/ai_service.dart:1-53`

## Troubleshooting

<AccordionGroup>
  <Accordion title="Integration shows as disconnected">
    * Verify your API key is correct
    * Check that the key hasn't expired in Google AI Studio
    * Ensure you saved the configuration
    * Try disconnecting and reconnecting the integration
  </Accordion>

  <Accordion title="AI extraction fails">
    * Verify Gemini integration is connected
    * Check your internet connection
    * Ensure the URL is publicly accessible
    * Some websites may block automated extraction
    * Review error message in the app for specific details
  </Accordion>

  <Accordion title="AI toggle is disabled">
    The AI features toggle requires:

    * Gemini integration to be connected first
    * Navigate to **Settings** → **Integrations** → **Google Gemini**
    * Complete the setup steps above
  </Accordion>

  <Accordion title="API quota exceeded">
    Google AI Studio has usage limits:

    * Check your quota in AI Studio dashboard
    * Consider upgrading your Google AI plan
    * Rate limits reset daily
  </Accordion>
</AccordionGroup>

## Security Best Practices

<Warning>
  **Never share your API key**. It provides direct access to your Google AI resources and usage quota.
</Warning>

* Store API keys securely using the integration settings (not in code)
* Rotate keys periodically in Google AI Studio
* Monitor usage in AI Studio to detect unauthorized access
* Use environment-specific keys for development vs production

## Related Documentation

* [Environment Configuration](/configuration/environment)
* [Integrations](/advanced/integrations)
* [Google AI Studio Documentation](https://ai.google.dev/docs)
