# Supported Embedding Providers in code-review-graph: Configuration Guide

> Discover supported embedding providers for code-review-graph including Gemini and OpenAI. Learn how to configure local sentence-transformers, Google Gemini, MiniMax, and OpenAI-compatible endpoints using environment variables.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: how-to-guide
- Published: 2026-07-29

---

**The code-review-graph repository supports four pluggable embedding providers—local (sentence-transformers), Google Gemini, MiniMax, and OpenAI-compatible endpoints—each activated via environment variables and the `get_provider()` factory in [`code_review_graph/embeddings.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/embeddings.py).**

code-review-graph implements a flexible embedding layer to power semantic code search across your repositories. The system abstracts vector generation through a provider pattern defined in [`code_review_graph/embeddings.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/embeddings.py), allowing you to switch between offline local models and cloud-based APIs without changing core logic. Understanding these **supported embedding providers** and their configuration options is essential for optimizing performance and maintaining data privacy.

## Overview of Embedding Providers

The embedding subsystem centers on the `get_provider()` factory function (lines 74-86 in [`code_review_graph/embeddings.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/embeddings.py)), which validates names against the `_VALID_PROVIDERS` set and returns concrete implementations:

- **LocalEmbeddingProvider**: Offline inference using `sentence-transformers` with no API keys required.
- **GoogleEmbeddingProvider**: Cloud-based Gemini embeddings via the `google-generativeai` client.
- **MiniMaxEmbeddingProvider**: MiniMax's proprietary `embo-01` 1536-dimensional embeddings.
- **OpenAIEmbeddingProvider`: Any OpenAI-compatible `/v1/embeddings` endpoint, including Azure OpenAI and self-hosted gateways.

## Configuring the Local Provider

The **LocalEmbeddingProvider** enables fully offline embedding generation, making it ideal for air-gapped environments. It lazily imports `sentence_transformers` and defaults to the `all-MiniLM-L6-v2` model unless overridden via `CRG_EMBEDDING_MODEL`.

```bash
export CRG_EMBEDDING_MODEL=all-MiniLM-L6-v2
python -m code_review_graph.main --provider local

```

If the `sentence_transformers` package is missing, the provider is unavailable and the system restricts you to cloud options only. No API keys or network access are required for this provider.

## Configuring the Google Gemini Provider

The **GoogleEmbeddingProvider** connects to Google's Gemini embedding API and requires the `google-generativeai` Python package. The constructor validates dependencies and raises explicit errors if the package is absent.

Set your configuration via environment variables:

```bash
export GOOGLE_API_KEY=YOUR_GEMINI_KEY
export CRG_EMBEDDING_MODEL=gemini-embedding-001  # optional override

python -m code_review_graph.main --provider google

```

This provider is categorized as a cloud provider in the `CLOUD_PROVIDERS` set (lines 28-30).

## Configuring the MiniMax Provider

The **MiniMaxEmbeddingProvider** interfaces with MiniMax's `embo-01` embedding service, producing 1536-dimensional vectors suitable for semantic similarity tasks.

Required configuration:

```bash
export MINIMAX_API_KEY=YOUR_MINIMAX_KEY
python -m code_review_graph.main --provider minimax

```

The API key is stored on the provider instance and used for every HTTP request to the MiniMax API.

## Configuring OpenAI-Compatible Providers

The **OpenAIEmbeddingProvider** supports any endpoint implementing the OpenAI `/v1/embeddings` specification, including official OpenAI, Azure OpenAI Service, and custom reverse proxies.

Required environment variables (validated in lines 22-27):

- `CRG_OPENAI_API_KEY`: Authentication token
- `CRG_OPENAI_BASE_URL`: Endpoint URL (e.g., `https://api.openai.com/v1`)
- `CRG_OPENAI_MODEL`: Model identifier (e.g., `text-embedding-3-small`)

Optional overrides:

- `CRG_OPENAI_DIMENSION`: Vector dimensionality
- `CRG_OPENAI_BATCH_SIZE`: Request batching limits

```bash
export CRG_OPENAI_API_KEY=sk-...
export CRG_OPENAI_BASE_URL=https://api.openai.com/v1
export CRG_OPENAI_MODEL=text-embedding-3-small
export CRG_OPENAI_DIMENSION=1536
python -m code_review_graph.main --provider openai

```

The constructor raises `ValueError` listing any missing required variables.

## Cloud Provider Safety Controls

All cloud providers (`google`, `minimax`, `openai`) emit a one-time warning to stderr before making outbound requests, as defined by the `CLOUD_PROVIDERS` constant. To acknowledge data transmission to third-party APIs and suppress this warning, set:

```bash
export CRG_ACCEPT_CLOUD_EMBEDDINGS=1

```

This safety mechanism is implemented in lines 45-52 of [`code_review_graph/embeddings.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/embeddings.py).

## Summary

- **Four providers available**: Local (sentence-transformers), Google (Gemini), MiniMax, and OpenAI-compatible, each with distinct latency and privacy characteristics.
- **Configuration method**: Environment variables for API keys and model selection, parsed by `get_provider()` in [`code_review_graph/embeddings.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/embeddings.py).
- **Offline capability**: The local provider requires no API keys but depends on the `sentence_transformers` package.
- **Safety features**: Cloud providers warn before API calls unless `CRG_ACCEPT_CLOUD_EMBEDDINGS=1` is exported.

## Frequently Asked Questions

### Which embedding provider works without an internet connection?

The **local** provider using `LocalEmbeddingProvider` operates entirely offline via `sentence-transformers`. You only need to install the Python package and optionally set `CRG_EMBEDDING_MODEL` to specify a model like `all-MiniLM-L6-v2`. No API keys or network connectivity are required.

### How do I migrate from OpenAI to Google Gemini embeddings?

Change your environment configuration by unsetting `CRG_OPENAI_*` variables and exporting `GOOGLE_API_KEY` with your Gemini API key. Then specify `--provider google` when running `code_review_graph.main`. The `get_provider()` factory automatically instantiates `GoogleEmbeddingProvider` based on the `provider` string passed to it.

### What triggers the cloud embedding warning in code-review-graph?

Any provider contained in the `CLOUD_PROVIDERS` set (`google`, `minimax`, `openai`) triggers a stderr warning before the first API request to alert you about data leaving your local network. Set `CRG_ACCEPT_CLOUD_EMBEDDINGS=1` to acknowledge this transmission and suppress the warning message.

### Can I use Azure OpenAI Service instead of the standard OpenAI API?

Yes. The **OpenAI-compatible** provider supports any `/v1/embeddings` endpoint. Configure `CRG_OPENAI_BASE_URL` to your Azure OpenAI endpoint (e.g., `https://YOUR_RESOURCE.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT/`) and provide the Azure API key in `CRG_OPENAI_API_KEY`. The system treats this as a standard OpenAI-compatible endpoint.