# How Roo Code’s Embedding Models System Supports Bedrock, Vertex, and OpenAI

> Explore how Roo Code's embedding models system unifies OpenAI, Bedrock, and Vertex embeddings using a provider-agnostic registry and dedicated embedder classes for seamless cloud integration.

- Repository: [Roo Code/Roo-Code](https://github.com/RooCodeInc/Roo-Code)
- Tags: architecture
- Published: 2026-04-26

---

**Roo Code unifies OpenAI, Amazon Bedrock, and Google Vertex embeddings through a provider-agnostic registry in [`src/shared/embeddingModels.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/shared/embeddingModels.ts) and dedicated embedder classes that implement the `IEmbedder` interface, enabling seamless switching between cloud providers via the `ServiceFactory`.**

The **Roo Code** extension (RooCodeInc/Roo-Code) implements a pluggable embedding models system that abstracts vector-store operations across multiple AI providers. By centralizing model metadata and provider-specific SDK handling, the system allows developers to switch between OpenAI, Bedrock, and Vertex embeddings without changing application logic.

## The Embedding Model Registry

Roo Code maintains a **single source of truth** for embedding model configurations in [`src/shared/embeddingModels.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/shared/embeddingModels.ts). The `EMBEDDING_MODEL_PROFILES` constant defines dimensionality and score thresholds for every supported model, ensuring the vector store validates incoming embeddings against the correct vector size.

```typescript
export const EMBEDDING_MODEL_PROFILES = {
  openai: {
    "text-embedding-3-small": { dimension: 1536, scoreThreshold: 0.4 },
    "text-embedding-3-large": { dimension: 3072, scoreThreshold: 0.4 },
    "text-embedding-ada-002": { dimension: 1536, scoreThreshold: 0.4 },
  },
  bedrock: {
    "amazon.titan-embed-text-v1": { dimension: 1536, scoreThreshold: 0.4 },
    "amazon.titan-embed-text-v2:0": { dimension: 1024, scoreThreshold: 0.4 },
    "cohere.embed-english-v3": { dimension: 1024, scoreThreshold: 0.4 },
    "cohere.embed-v4:0": { dimension: 1536, scoreThreshold: 0.4 },
    "amazon.nova-2-multimodal-embeddings-v1:0": { dimension: 1024, scoreThreshold: 0.4 },
  },
  gemini: {
    "gemini-embedding-001": { dimension: 3072, scoreThreshold: 0.4 },
  },
};

```

Utility functions like `getModelDimension` and `getDefaultModelId` perform runtime lookups against this registry. When initializing the Qdrant vector store, Roo Code calls `getModelDimension` to enforce that the collection's vector size matches the selected model's output.

## Provider-Specific Embedder Implementations

The embedding models system implements the **IEmbedder** contract through provider-specific classes located in `src/services/code-index/embedders/`. Each class handles native SDK integration, batching, and retry logic.

### OpenAI Embedder

The `OpenAIEmbedder` class in [`src/services/code-index/embedders/openai.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/services/code-index/embedders/openai.ts) uses the official `openai` NPM package to generate embeddings.

```typescript
export class OpenAIEmbedder implements IEmbedder {
  private embeddingsClient: OpenAI;

  constructor(private apiKey: string, private modelId = "text-embedding-3-small") {
    this.embeddingsClient = new OpenAI({ apiKey });
  }
  
  // Implements embedBatch using embeddingsClient.embeddings.create()
}

```

### Amazon Bedrock Embedder

The `BedrockEmbedder` in [`src/services/code-index/embedders/bedrock.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/services/code-index/embedders/bedrock.ts) integrates with AWS using the `@aws-sdk/client-bedrock-runtime` package.

```typescript
export class BedrockEmbedder implements IEmbedder {
  private bedrockClient: BedrockRuntimeClient;

  constructor(region: string, profile?: string, private modelId = "amazon.titan-embed-text-v2:0") {
    if (!region) throw new Error("Region is required for AWS Bedrock embedder");
    this.bedrockClient = new BedrockRuntimeClient({ 
      region, 
      credentials: /* from profile or env */ 
    });
  }
  
  // _embedBatchWithRetries uses InvokeModelCommand on the Bedrock runtime
}

```

### Google Vertex (Gemini) Embedder

For **Vertex AI**, Roo Code uses the `GeminiEmbedder` class (also in [`src/services/code-index/embedders/gemini.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/services/code-index/embedders/gemini.ts)), which wraps an `OpenAICompatibleEmbedder` configured to communicate with Vertex's Gemini endpoint. The class leverages the `VertexHandler` from [`src/api/providers/vertex.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/api/providers/vertex.ts) to manage authentication and project-specific routing, supporting models like `gemini-embedding-001`.

## Factory Pattern and Configuration Validation

The `ServiceFactory` in [`src/services/code-index/service-factory.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/services/code-index/service-factory.ts) instantiates the correct embedder based on user configuration stored in the extension state.

```typescript
export class EmbedderFactory {
  static create(config: CodebaseIndexConfig): IEmbedder {
    switch (config.embedderProvider) {
      case "openai":
        return new OpenAIEmbedder(config.openAiOptions.apiKey, config.modelId);
      case "bedrock":
        return new BedrockEmbedder(
          config.bedrockOptions.region,
          config.bedrockOptions.profile,
          config.modelId
        );
      case "vertex":
        return new GeminiEmbedder(
          config.vertexOptions, // contains projectId, region, credentials
          config.modelId
        );
      default:
        throw new Error(`Unsupported embedder provider: ${config.embedderProvider}`);
    }
  }
}

```

Before instantiation, the UI validates provider-specific fields in [`webview-ui/src/utils/validate.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/webview-ui/src/utils/validate.ts). Bedrock requires a region, Vertex requires a project ID and region, and OpenAI requires an API key.

## Practical Implementation Example

The following example demonstrates how to initialize the embedding models system programmatically:

```typescript
import { ServiceFactory } from "@/services/code-index/service-factory";
import { getModelDimension } from "@/shared/embeddingModels";

// Configure for Amazon Bedrock
const cfg = {
  embedderProvider: "bedrock",
  modelId: "amazon.titan-embed-text-v2:0",
  bedrockOptions: { region: "us-east-1", profile: "default" },
};

// Instantiate the embedder
const embedder = ServiceFactory.create(cfg);

// Get expected dimension for vector store creation
const dimension = getModelDimension("bedrock", cfg.modelId); // Returns 1024

// Generate embeddings
const texts = ["Roo Code makes vector search easy.", "Embedding models are pluggable."];
const { embeddings, error } = await embedder.embedBatch(texts);

if (error) {
  console.error("Embedding failed:", error);
} else {
  console.log(`Generated ${embeddings.length} vectors of dimension ${dimension}`);
}

```

To switch to OpenAI, change `embedderProvider` to `"openai"` and provide an API key. For Vertex, use `"vertex"` with a Gemini model ID like `"gemini-embedding-001"`.

## Summary

- **`EMBEDDING_MODEL_PROFILES`** in [`src/shared/embeddingModels.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/shared/embeddingModels.ts) centralizes model dimensions and thresholds for OpenAI, Bedrock Titan/Cohere, and Gemini embeddings.
- **Provider-specific embedders** (`OpenAIEmbedder`, `BedrockEmbedder`, `GeminiEmbedder`) implement the `IEmbedder` interface with native SDK integration and retry logic.
- **`ServiceFactory`** reads extension settings to instantiate the correct embedder, while [`webview-ui/src/utils/validate.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/webview-ui/src/utils/validate.ts) enforces required configuration fields.
- **Dimension enforcement** occurs at vector-store creation via `getModelDimension`, preventing mismatched vector sizes between the embedding model and Qdrant collection.

## Frequently Asked Questions

### How does Roo Code handle different vector dimensions across embedding providers?

Roo Code stores dimension metadata in the `EMBEDDING_MODEL_PROFILES` registry located at [`src/shared/embeddingModels.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/shared/embeddingModels.ts). When creating a vector store, the system calls `getModelDimension` to retrieve the expected size for the selected model—such as 1024 for Bedrock's Titan v2 or 3072 for OpenAI's text-embedding-3-large—and configures the Qdrant collection accordingly.

### What authentication methods does the Bedrock embedder support?

The `BedrockEmbedder` class in [`src/services/code-index/embedders/bedrock.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/services/code-index/embedders/bedrock.ts) accepts a region and optional profile name during instantiation. It initializes the `BedrockRuntimeClient` from `@aws-sdk/client-bedrock-runtime` using credentials derived from the specified AWS profile or environment variables, following standard AWS credential chain precedence.

### Can I use Vertex AI embeddings without modifying the core embedding logic?

Yes. The `GeminiEmbedder` acts as a compatibility layer that routes requests through the `VertexHandler` in [`src/api/providers/vertex.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/api/providers/vertex.ts). You simply select `"vertex"` as the `embedderProvider` and provide your Vertex project ID and region; the factory pattern handles the instantiation without requiring changes to the embedding batching or storage logic.

### Which Bedrock embedding models are supported by Roo Code?

According to the source code in [`src/shared/embeddingModels.ts`](https://github.com/RooCodeInc/Roo-Code/blob/main/src/shared/embeddingModels.ts), Roo Code supports Amazon Titan Embeddings (v1 and v2), Cohere Embed models (English v3 and v4), and Amazon Nova multimodal embeddings through the Bedrock provider, each with specific dimension configurations ranging from 1024 to 1536 dimensions.