# How to Switch Between Embedding Providers in DeepWiki: OpenAI, Google AI, and Ollama

> Effortlessly switch embedding providers in DeepWiki between OpenAI Google AI and Ollama. Use environment variables or direct calls to change embedders instantly.

- Repository: [ASYNCFUNC/deepwiki-open](https://github.com/asyncfuncai/deepwiki-open)
- Tags: how-to-guide
- Published: 2026-02-16

---

**Set the `DEEPWIKI_EMBEDDER_TYPE` environment variable to `openai`, `google`, or `ollama`, or call `get_embedder(embedder_type="google")` directly to instantly switch between embedding providers without modifying source code.**

DeepWiki implements a runtime configuration layer that decouples the embedding backend from application logic, allowing you to **switch between embedding providers** seamlessly. According to the AsyncFuncAI/deepwiki-open source code, the system loads client classes dynamically based on environment variables and JSON configuration files, supporting OpenAI, Google AI, Ollama, and Bedrock through a unified factory interface.

## Configuration Architecture

The embedding system relies on two core configuration sources that determine which provider handles document vectorization.

### Environment Variable Configuration

The default provider is resolved at runtime from the `DEEPWIKI_EMBEDDER_TYPE` environment variable, as defined in [`api/config.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/config.py) (line 52):

```python
EMBEDDER_TYPE = os.environ.get('DEEPWIKI_EMBEDDER_TYPE', 'openai').lower()

```

Valid values include `openai`, `google`, `ollama`, and `bedrock`. When unset, the system defaults to OpenAI.

### JSON Configuration Registry

Provider-specific settings reside in [`api/config/embedder.json`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/config/embedder.json), mapping each provider to its client class and default model:

- **OpenAI** → `OpenAIClient` with `text-embedding-3-small`
- **Google AI** → `GoogleEmbedderClient` with `text-embedding-004`
- **Ollama** → `OllamaClient` with `nomic-embed-text`

The `get_embedder()` function in [`api/tools/embedder.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/tools/embedder.py) (lines 6-42) reads this registry and constructs an **AdalFlow** `Embedder` instance using the specified configuration block.

## Three Methods to Switch Providers

DeepWiki offers three interchangeable approaches to change embedding backends without code redeployment.

### Method 1: Environment Variable (Recommended for Deployment)

Set the environment variable before server initialization to configure the global default:

```bash
export DEEPWIKI_EMBEDDER_TYPE=google

# or ollama, openai, bedrock

```

This value is processed by `get_embedder_type()` in [`api/config.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/config.py) (lines 38-52), which maps the configuration to a canonical provider name used throughout the application.

### Method 2: Direct Function Argument (Recommended for Testing)

Call `get_embedder()` with an explicit `embedder_type` parameter to override the environment default for specific instances:

```python
from api.tools.embedder import get_embedder

# Switch to Google AI

google_emb = get_embedder(embedder_type='google')

# Switch to Ollama local instance

ollama_emb = get_embedder(embedder_type='ollama')

# Explicit OpenAI selection

openai_emb = get_embedder(embedder_type='openai')

```

This method instantiates the requested provider immediately without affecting the global configuration state.

### Method 3: Legacy Boolean Flags (Backward Compatibility)

For existing codebases using deprecated flags, [`api/tools/embedder.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/tools/embedder.py) still supports boolean switches that map to the appropriate configuration:

```python
from api.tools.embedder import get_embedder

# Legacy Ollama flag

ollama_emb = get_embedder(is_local_ollama=True)

# Legacy Google flag

google_emb = get_embedder(use_google_embedder=True)

```

These flags are internally translated to the corresponding `embedder_type` values to maintain compatibility with earlier DeepWiki versions.

## Implementation Details

The provider switching mechanism centers on a factory pattern implemented in two key modules.

### Configuration Loading in [`api/config.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/config.py)

The `get_embedder_type()` function normalizes provider selection by checking the environment variable and returning a standardized lowercase string. This ensures consistent provider identification across the application layer.

### Factory Construction in [`api/tools/embedder.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/tools/embedder.py)

The `get_embedder()` factory performs three critical operations:

1. **Config Resolution**: Loads the appropriate block from the `configs` dictionary based on `embedder_type`
2. **Client Instantiation**: Dynamically imports and instantiates the client class specified in [`embedder.json`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/embedder.json) (e.g., `GoogleEmbedderClient`, `OpenAIClient`, or `OllamaClient`)
3. **AdalFlow Wrapper**: Wraps the native client in an `adalflow.Embedder` instance for standardized vectorization operations

Because configuration loads at import time, changing providers requires only an environment variable update or new function call—subsequent requests automatically utilize the new embedding backend without server restarts or code changes.

## Summary

- **Environment Variable**: Set `DEEPWIKI_EMBEDDER_TYPE` to `openai`, `google`, `ollama`, or `bedrock` in [`api/config.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/config.py) to switch global defaults
- **Direct Injection**: Pass `embedder_type='google'` (or `'ollama'`, `'openai'`) to `get_embedder()` in [`api/tools/embedder.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/tools/embedder.py) for instance-specific selection
- **Legacy Support**: Boolean flags `is_local_ollama` and `use_google_embedder` continue to function for backward compatibility
- **No Code Changes Required**: The JSON-based configuration in [`api/config/embedder.json`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/config/embedder.json) and runtime factory pattern eliminate the need for source modifications when switching between OpenAI, Google AI, and Ollama providers

## Frequently Asked Questions

### How do I configure API keys for different embedding providers?

Each client class loads its own authentication credentials from environment variables specific to the provider. For OpenAI, the client in [`api/openai_client.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/openai_client.py) expects `OPENAI_API_KEY`. For Google AI, [`api/google_embedder_client.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/google_embedder_client.py) requires `GOOGLE_API_KEY`. Ollama typically requires no key for local instances, as implemented in [`api/ollama_patch.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/ollama_patch.py).

### Can I use multiple embedding providers simultaneously in the same application?

Yes. While the global default is set via `DEEPWIKI_EMBEDDER_TYPE`, individual components can instantiate different providers by calling `get_embedder(embedder_type='ollama')` alongside others using `embedder_type='openai'`. Each call returns an independent `adalflow.Embedder` instance configured for the specified backend.

### What embedding models are available for each provider?

According to [`api/config/embedder.json`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/config/embedder.json), the default configurations specify `text-embedding-3-small` for OpenAI, `text-embedding-004` for Google AI, and `nomic-embed-text` for Ollama. You can modify these model identifiers in the JSON configuration file to use alternative models supported by each provider's API.

### Is there a performance difference between local Ollama and cloud providers?

Ollama runs locally via [`api/ollama_patch.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/ollama_patch.py) and incurs network latency only to the local host, eliminating external API round trips. OpenAI and Google AI clients in [`api/openai_client.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/openai_client.py) and [`api/google_embedder_client.py`](https://github.com/AsyncFuncAI/deepwiki-open/blob/main/api/google_embedder_client.py) respectively require HTTPS requests to external endpoints, introducing variable latency based on network conditions and provider rate limits.