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

# Google Gemini Integration

> Configure Google's Gemini models for AI calling. Google's Gemini models provide powerful language understanding with excellent performance.This guide covers setup and best practices.

## Available Models

### Gemini Pro (Recommended)

**Model**: `gemini-pro`

```
Capabilities:
- Fast responses
- Excellent reasoning
- Good for most use cases
- Strong cost/quality balance

Cost: ~$0.0005 per 1K tokens
Speed: < 2 seconds response time
Best For: General customer service, lead generation
```

### Gemini Pro Vision

**Model**: `gemini-pro-vision`

```
Capabilities:
- All Gemini Pro features
- Plus image understanding
- Analyze documents and images
- Process receipts, IDs, etc.

Cost: ~$0.001 per 1K input tokens
Speed: 2-3 seconds
Best For: Document processing, verification tasks
```

## Setup

### Step 1: Get API Key

1. Go to [Google AI Studio](https://makersuite.google.com/app/apikey)
2. Click "Create API Key"
3. Select your GCP project
4. Copy the API key

```
Example Format:
AIzaSyDXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

### Step 2: Enable Gemini API

In Google Cloud Console:

1. Go to [Google Cloud Console](https://console.cloud.google.com)
2. Search for "Generative Language API"
3. Click "Enable"
4. Wait for API to activate (usually instant)

### Step 3: Add to CallIntel

**For Super Admins:**

1. Go to Settings → Developer Settings
2. Click "API Keys"
3. Select "Google Gemini" from provider list
4. Paste API key
5. Click "Test Connection"
6. Save

**For Organization Admins:**

1. Go to Settings → AI Models
2. Click "Add Google Gemini"
3. Paste API key
4. Select which models to enable
5. Save

### Step 4: Configure Agent

1. Create or Edit an Agent
2. Under "Language Model", select:
   * `gemini-pro` or
   * `gemini-pro-vision`
3. Configure settings:
   * **Temperature**: 0.7 (default)
   * **Max Tokens**: 200
4. Save agent

### Step 5: Test

Make a test call:

1. Use Web Call feature
2. Speak with agent
3. Verify responses
4. Check logs

## Model Selection

### Gemini vs OpenAI

| Feature          | Gemini | GPT-3.5 |
| ---------------- | ------ | ------- |
| Quality          | ⭐⭐⭐⭐⭐  | ⭐⭐⭐⭐    |
| Speed            | ⭐⭐⭐⭐⭐  | ⭐⭐⭐⭐⭐   |
| Cost             | ⭐⭐⭐⭐⭐  | ⭐⭐⭐⭐    |
| Vision           | ✓      | ✗       |
| Function Calling | ✓      | ✓       |

### When to Use Gemini

**Advantages:**

* Slightly cheaper than GPT-3.5
* Faster responses
* Native vision support
* Great for document analysis
* Excellent multilingual support

**Best Use Cases:**

* High-volume customer service
* Document verification
* Multilingual agents
* Vision-based tasks
* Cost-sensitive operations

## Configuration

### Temperature

Controls response variability (0-2):

```
Conservative: 0.3-0.5
Balanced: 0.7 (default)
Creative: 1.0-1.5
```

### Top P

Controls diversity (0-1):

```
0.8 = More focused
0.95 = More diverse
Default: 0.95
```

### Top K

Controls output (1-40):

```
1 = Most likely token
40 = More diversity
Default: 40
```

## Cost Comparison

### Monthly Costs (1000 calls)

```
OpenAI GPT-3.5:
1000 calls × 500 tokens × $0.0000005 = $0.25/month

Google Gemini:
1000 calls × 500 tokens × $0.0000005 = $0.25/month

Savings: Similar cost, but Gemini is slightly faster
```

### Gemini Vision Costs

```
Image Analysis:
Per call: ~$0.01 (with image)
Text-only: ~$0.0005

Best For:
- Document scanning
- Receipt processing
- Identity verification
- Limited use cases (cost matters)
```

## Advanced Features

### Image Analysis

Process images with Gemini Pro Vision:

```
Supported Inputs:
- JPEG images
- PNG images
- GIF images
- PDF documents

Use Cases:
- Receipt analysis
- Document scanning
- Quality inspection
- ID verification
```

**Cost Note**: Image processing is more expensive per call.

### Function Calling

Enable agents to interact with external systems:

```json theme={null}
{
  "name": "lookup_customer",
  "description": "Find customer information",
  "parameters": {
    "type": "object",
    "properties": {
      "customer_id": {
        "type": "string",
        "description": "The customer ID"
      }
    }
  }
}
```

### Streaming Responses

Get responses progressively:

```
Traditional: Wait for entire response (slower)
Streaming: Get tokens as they're generated (faster perceived speed)
Better for: Real-time interactions
```

## Optimization

### 1. Use Gemini for High Volume

```
High-volume calling (>1000/month):
→ Gemini Pro (same cost, faster)
→ Save response time costs
```

### 2. Optimize Prompts

Keep system prompts concise:

```
Bad: Long detailed instructions
Good: 1-2 sentence instructions
Savings: 40-50% fewer tokens
```

### 3. Reduce Token Usage

```
Technique        | Impact
-----------------|-------
Shorter KB       | 30-50%
Concise prompts  | 20-40%
Lower max_tokens | 10-30%

Combined: 50% reduction possible
```

## Monitoring

### API Usage

Check Gemini API usage:

1. Go to [Google AI Studio](https://makersuite.google.com/app/apikey)
2. View usage statistics
3. Check spending rate
4. Monitor quota limits

### Call Metrics

Track in CallIntel dashboard:

```
- Average response time
- Success rate
- Token usage
- Cost per call
- Error rate
```

## Best Practices

### 1. Start with Gemini Pro

```
Perfect for: Customer service, lead generation, general conversations
Cost-effective and fast
```

### 2. Use Vision Sparingly

```
Gemini Pro Vision costs more
Use for: Document verification, quality checks
Pair with Gemini Pro for regular calls
```

### 3. Monitor Response Quality

```
Weekly Review:
- Sample 10-20 calls
- Check response accuracy
- Verify tone and style
- Look for errors
- Adjust prompts if needed
```

### 4. Test Before Deploying

```
1. Create test agent with Gemini
2. Make 20 test calls
3. Compare with other models
4. Measure quality and cost
5. Deploy if satisfied
```

## Troubleshooting

<Accordion title="Getting 'API key invalid' error">
  Verify key format is correct, API is enabled in Google Cloud Console, and key is for Gemini API.
</Accordion>

<Accordion title="Responses are slower than expected">
  Gemini is typically fast, but check network latency. Try reducing max\_tokens.
</Accordion>

<Accordion title="Vision requests failing">
  Ensure image format is supported (JPEG, PNG, GIF). Check file size isn't too large.
</Accordion>

<Accordion title="Cost is higher than expected">
  Check if using vision model. Vision requests cost 2-3x more. Switch to Gemini Pro for text-only.
</Accordion>

***

## See Also

<CardGroup cols={3}>
  <Card title="AI Models Overview" icon="star" href="/guides/integrations/ai-models/overview">
    Compare all AI providers
  </Card>

  <Card title="OpenAI Models" icon="code" href="/guides/integrations/ai-models/openai">
    Using OpenAI models
  </Card>

  <Card title="Agent Setup" icon="robot" href="/guides/core-concepts/agents">
    Create and configure agents
  </Card>
</CardGroup>

***

## Support

<CardGroup cols={2}>
  <Card title="Google Gemini Docs" icon="code">
    [View Gemini API Documentation](https://ai.google.dev)
  </Card>

  <Card title="Contact Support" icon="envelope">
    Email: [callintel01@gmail.com](mailto:callintel01@gmail.com)
  </Card>
</CardGroup>
