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

# Gemini Configuration

> Set up Google Gemini for AI analysis

# Gemini Configuration

Configure Google Gemini to power Simili Bot's AI capabilities.

## What is Gemini?

Google Gemini provides:

* **Text Embeddings**: Convert issues to semantic vectors for similarity search
* **LLM Analysis**: AI-powered duplicate detection, routing, triage, and quality assessment
* **Fast Processing**: Cloud-based inference with minimal latency

## Getting started

### 1. Get API key

1. Go to [Google AI Studio](https://aistudio.google.com/app/apikeys)
2. Sign in with your Google account
3. Click **Get API key**
4. Choose or create a Google Cloud project
5. Copy the generated API key

### 2. Set up GitHub secret

Store your API key securely:

1. Go to repository **Settings** → **Secrets and variables** → **Actions**
2. Create secret `GEMINI_API_KEY`
3. Paste your API key

### 3. Configure Simili Bot

Add to `simili.yaml`:

```yaml theme={null}
embedding:
  provider: "gemini"
  api_key: "${GEMINI_API_KEY}"
  model: "gemini-embedding-001"
  dimensions: 3072

llm:
  provider: "gemini"
  model: "gemini-2.5-flash"
```

## Configuration reference

### Embedding settings

```yaml theme={null}
embedding:
  provider: "gemini"
  api_key: "${GEMINI_API_KEY}"
  model: "gemini-embedding-001"
  dimensions: 3072
```

| Property     | Type   | Description                          | Default                | Required |
| ------------ | ------ | ------------------------------------ | ---------------------- | -------- |
| `provider`   | string | Must be "gemini"                     | -                      | Yes      |
| `api_key`    | string | API key from Google AI Studio        | -                      | Yes      |
| `model`      | string | Embedding model to use               | `gemini-embedding-001` | No       |
| `dimensions` | number | Vector dimensions (must match model) | 3072                   | No       |

### LLM settings

```yaml theme={null}
llm:
  provider: "gemini"
  api_key: "${GEMINI_API_KEY}"
  model: "gemini-2.5-flash"
```

| Property   | Type   | Description                       | Default                 |
| ---------- | ------ | --------------------------------- | ----------------------- |
| `provider` | string | Must be "gemini"                  | Inherits from embedding |
| `api_key`  | string | API key (can reuse embedding key) | Inherits from embedding |
| `model`    | string | LLM model to use                  | `gemini-2.5-flash`      |

### Available models

| Model                   | Type       | Dimensions | Notes                 |
| ----------------------- | ---------- | ---------- | --------------------- |
| `gemini-embedding-001`  | Embeddings | 3072       | Default (recommended) |
| `gemini-2.5-flash`      | LLM        | -          | Default LLM           |
| `gemini-2.0-flash-lite` | LLM        | -          | Lighter/faster option |

<Note>
  v0.1.0 used `text-embedding-004` (768 dimensions). If upgrading from v0.1.0, update your config to `gemini-embedding-001` (3072 dimensions) and re-index your Qdrant collection.
</Note>

## Pricing

Google Gemini offers a free tier:

**Free Tier:**

* Embeddings: 50 requests per minute
* LLM: 15 requests per minute
* Generous monthly quotas

**Paid (if needed):**

* Pay-as-you-go pricing
* No monthly minimum
* Bulk discounts available

**Estimate for 1000 issues:**

* Embeddings: \~\$0.01-0.05
* LLM analysis: \$0.10-0.50 (depending on feature usage)

## Common issues & solutions

### API key not valid

**Error:** `Error 400: Invalid API key`

**Solutions:**

1. Verify key is correct from Google AI Studio
2. Check key hasn't expired or been revoked
3. Ensure no extra spaces in secret value
4. Try regenerating key in Google AI Studio
5. Verify project has API enabled

### Rate limited

**Error:** `Error 429: Rate limit exceeded`

**Solutions:**

1. For free tier: Add delays between API calls
2. Reduce batch size for embeddings
3. Upgrade to paid plan if consistent usage
4. Distribute processing over time

### Model not found

**Error:** `model 'gemini-embedding-001' not found`

**Solutions:**

1. Check model name spelling exactly
2. Verify Google has enabled this model in your region
3. Try default model by omitting `model` setting
4. Check project has sufficient quota

## Advanced configuration

### Batch processing

For bulk indexing, control batch size:

```yaml theme={null}
embedding:
  provider: "gemini"
  api_key: "${GEMINI_API_KEY}"
  batch_size: 50  # Smaller = more requests, less rate limiting
```

Smaller batches help with rate limiting but increase request count.

### Custom prompts

LLM analysis uses templated prompts for:

* Duplicate detection
* Quality assessment
* Issue routing
* Label suggestions

These are built-in and optimized for Gemini.

## Integration points

Gemini is used for:

### 1. Embeddings (for all issues)

```
Issue text → Embedding → Vector storage
```

### 2. Similarity search (optional, if configured)

```
Find similar issues → Return top N
```

### 3. Duplicate detection (optional)

```
Compare similar issues → AI analysis → Confidence score
```

### 4. Quality assessment (optional)

```
Analyze issue description → Score → Suggestions
```

### 5. Auto triage (optional)

```
Analyze issue → Suggest labels → Post to GitHub
```

### 6. Smart routing (optional)

```
Analyze issue + repositories → Route decision
```

## Monitoring API usage

### In Google AI Studio

1. Go to [Google AI Studio](https://aistudio.google.com/app/apikeys)
2. Click your API key
3. View usage and quotas

### Common metrics

* Tokens processed
* Requests made
* Current month usage
* Rate limit status

## Cost optimization

### Reduce API calls

**Use workflow presets:**

```bash theme={null}
# Only index, no AI analysis
simili process --workflow index-only

# Only semantic search, no LLM
simili process --workflow similarity-only
```

**Disable features you don't need:**

```yaml theme={null}
# In transfer config, disable LLM routing
transfer:
  llm_routing_enabled: false
```

### Batch operations

Index multiple issues together:

```bash theme={null}
# Bulk index with 10 workers
simili index --repo owner/repo --since 30d --workers 10
```

Batching reduces per-issue overhead.

### Archive old issues

Periodically clean up:

1. Close resolved issues
2. Archive old discussions
3. Reduces embedding storage costs in Qdrant

## Testing

### Verify configuration

```bash theme={null}
export GEMINI_API_KEY="your-key"
simili process --issue test.json --config simili.yaml --dry-run
```

Should output analysis without errors.

### Test dry-run

Try without posting to GitHub:

```bash theme={null}
simili process --issue test.json --config simili.yaml --dry-run
```

### Monitor logs

Check output for:

* Successful embeddings
* API response times
* Error messages
* Rate limit warnings

## Next steps

<CardGroup cols={2}>
  <Card title="Qdrant setup" href="/configuration/qdrant">
    Configure vector database
  </Card>

  <Card title="Configuration overview" href="/configuration/overview">
    View all configuration options
  </Card>

  <Card title="Semantic search guide" href="/guides/semantic-search">
    Learn how semantic search works
  </Card>
</CardGroup>
