# What Embedding Models Does AstrBot Support for Its Knowledge Base?

> Discover AstrBot's supported embedding models for your knowledge base. Explore options from OpenAI and Google Gemini to enhance your bot's understanding and performance.

- Repository: [AstrBot AI/AstrBot](https://github.com/AstrBotDevs/AstrBot)
- Tags: deep-dive
- Published: 2026-03-12

---

**AstrBot supports OpenAI and Google Gemini embedding models out of the box, defaulting to `text-embedding-3-small` and `gemini-embedding-exp-03-07` respectively.**

AstrBot is an extensible AI chatbot framework that includes a knowledge base system for storing and retrieving vectorized text representations. Understanding what embedding models AstrBot supports is essential for configuring accurate semantic search and retrieval-augmented generation (RAG) capabilities. The framework provides built-in adapters for industry-leading embedding providers through a unified `EmbeddingProvider` interface.

## Built-In Embedding Providers in AstrBot

AstrBot ships with two production-ready embedding providers that implement the abstract `EmbeddingProvider` class defined in [`astrbot/core/provider/provider.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/provider.py). Both providers register themselves with the `@register_provider_adapter` decorator, making them available to the `ProviderManager` in [`astrbot/core/provider/manager.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/manager.py).

### OpenAI Embedding Provider

The **OpenAI Embedding Provider** connects to OpenAI or Azure OpenAI API endpoints to generate embeddings. According to the source code in [`astrbot/core/provider/sources/openai_embedding_source.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/sources/openai_embedding_source.py), this provider defaults to the `text-embedding-3-small` model when no specific model is configured.

Key configuration parameters:

- `embedding_model`: Model identifier (default: `text-embedding-3-small`, supports `text-embedding-3-large` or custom Azure deployments)
- `embedding_api_key`: Authentication key for the OpenAI API
- `embedding_api_base`: Optional endpoint URL for Azure OpenAI or proxy configurations
- `embedding_dimensions`: Vector dimensionality (default: 1024)

The provider calls `client.embeddings.create()` with the specified model and passes the `dimensions` parameter when `get_dim()` returns a non-None value.

### Google Gemini Embedding Provider

The **Google Gemini Embedding Provider** interfaces with Google's Gemini API to generate vector representations. As implemented in [`astrbot/core/provider/sources/gemini_embedding_source.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/sources/gemini_embedding_source.py), this provider defaults to the `gemini-embedding-exp-03-07` model.

Key configuration parameters:

- `embedding_model`: Model identifier (default: `gemini-embedding-exp-03-07`)
- `embedding_api_key`: Google AI Studio API key
- `embedding_dimensions`: Vector dimensionality (default: 768)

This provider utilizes `client.models.embed_content()` with an `EmbedContentConfig` object that specifies the desired output dimensionality. The `GeminiEmbeddingProvider.get_dim()` method returns 768 by default, matching the Gemini embedding specification.

## Configuring Embedding Models in AstrBot

Embedding configuration resides in the global configuration schema defined in [`astrbot/core/config/default.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/config/default.py) (approximately lines 1610–1650). To activate an embedding provider for your knowledge base, specify the provider ID and model parameters in your configuration file.

```yaml
knowledgebase:
  embedding_provider_id: openai_embedding
  embedding_provider_config:
    embedding_api_key: sk-your-openai-key
    embedding_model: text-embedding-3-large
    embedding_dimensions: 1536
    embedding_api_base: https://api.openai.com/v1

```

For Google Gemini:

```yaml
knowledgebase:
  embedding_provider_id: gemini_embedding
  embedding_provider_config:
    embedding_api_key: your-gemini-api-key
    embedding_model: gemini-embedding-exp-03-07
    embedding_dimensions: 768

```

## Using Embedding Providers Programmatically

Both providers implement the `EmbeddingProvider` abstract class, exposing `get_embedding()` for single texts and `get_embeddings()` for batches. The `ProviderManager` in [`astrbot/core/provider/manager.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/manager.py) handles instantiation and dependency injection.

```python
from astrbot.core.provider.manager import ProviderManager

async def generate_embeddings():
    # Obtain the provider manager instance

    prov_mgr = ProviderManager.get_instance()
    
    # Retrieve the OpenAI embedding provider

    openai_ep = await prov_mgr.get_provider_by_id("openai_embedding")
    
    # Generate embedding for a single text

    text = "AstrBot is an extensible AI chatbot framework."
    vector = await openai_ep.get_embedding(text)
    print(f"Generated vector with dimension: {len(vector)}")
    
    # Batch processing

    texts = ["Hello world", "Knowledge base retrieval"]
    vectors = await openai_ep.get_embeddings(texts)
    return vectors

```

The `KnowledgeBaseHelper` class in [`astrbot/core/knowledge_base/kb_helper.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/knowledge_base/kb_helper.py) orchestrates these calls to index documents and perform similarity searches against the vector store.

## Summary

- AstrBot supports **OpenAI** and **Google Gemini** embedding providers out of the box through the `EmbeddingProvider` interface.
- Default models are `text-embedding-3-small` (OpenAI, 1024 dimensions) and `gemini-embedding-exp-03-07` (Gemini, 768 dimensions).
- Configuration occurs in [`astrbot/core/config/default.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/config/default.py) with keys `embedding_model`, `embedding_api_key`, and `embedding_api_base`.
- Provider implementations reside in [`astrbot/core/provider/sources/openai_embedding_source.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/sources/openai_embedding_source.py) and [`astrbot/core/provider/sources/gemini_embedding_source.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/sources/gemini_embedding_source.py).
- Both providers expose identical async methods `get_embedding()` and `get_embeddings()` for single and batch processing.

## Frequently Asked Questions

### Can I use custom embedding models with AstrBot?

Yes, you can specify any model name supported by the underlying API in the `embedding_model` configuration field. For OpenAI, this includes `text-embedding-3-large` or custom Azure OpenAI deployment names. For Gemini, you can use newer experimental models as they become available in the Google AI Studio API.

### What is the default embedding dimension for AstrBot providers?

The OpenAI provider defaults to **1024 dimensions** when using `text-embedding-3-small`, while the Gemini provider defaults to **768 dimensions** for `gemini-embedding-exp-03-07`. You can override these via the `embedding_dimensions` configuration key, though the underlying service must support the requested dimensionality.

### How do I switch between OpenAI and Gemini embeddings?

Change the `embedding_provider_id` in your knowledge base configuration to either `openai_embedding` or `gemini_embedding`. After switching, you should rebuild your knowledge base vectors using the `rebuild_vectors()` method in `KnowledgeBaseHelper` to ensure all documents are embedded with the new model.

### Where are the embedding provider implementations located?

The concrete implementations are located in [`astrbot/core/provider/sources/openai_embedding_source.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/sources/openai_embedding_source.py) for OpenAI and [`astrbot/core/provider/sources/gemini_embedding_source.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/sources/gemini_embedding_source.py) for Gemini. The abstract interface they implement is defined in [`astrbot/core/provider/provider.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/provider.py), and the registration logic resides in [`astrbot/core/provider/manager.py`](https://github.com/AstrBotDevs/AstrBot/blob/main/astrbot/core/provider/manager.py).