# Where to Find the Vane Model Registry Implementation: Complete Guide

> Locate the Vane model registry implementation in the ModelRegistry class at ItzCrazyKns/Vane. Discover provider loading, model discovery, and lifecycle management features.

- Repository: [Kushagra Srivastava/Vane](https://github.com/ItzCrazyKns/Vane)
- Tags: how-to-guide
- Published: 2026-03-11

---

**The Vane model registry implementation is located in the `ModelRegistry` class within [`src/lib/models/registry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/registry.ts), which handles provider loading, model discovery, and lifecycle management.**

The ItzCrazyKns/Vane repository uses a centralized registry pattern to abstract interactions with multiple LLM and embedding providers. Understanding the Vane model registry implementation is essential for developers extending the system or integrating custom AI backends. This registry acts as the single source of truth for discovering, loading, and managing model providers across the application.

## Core Implementation: The ModelRegistry Class

The heart of the system resides in [`src/lib/models/registry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/registry.ts), where the `ModelRegistry` class orchestrates all model-related operations. This class implements a façade pattern that shields the rest of the application from provider-specific implementation details while exposing a uniform interface for chat and embedding models.

### Provider Loading and Initialization

During instantiation, the registry reads server configuration via `getConfiguredModelProviders` and constructs concrete provider instances through `createProviderInstance`. In [`src/lib/models/registry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/registry.ts) (lines 17-34), the initialization logic validates raw configuration objects and instantiates the appropriate provider classes defined in `src/lib/models/providers/`. This process ensures that only properly configured providers enter the active pool.

### Model Discovery and Loading

The `getActiveProviders()` method (lines 37-72 in [`src/lib/models/registry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/registry.ts)) aggregates available models from each provider, returning a standardized `MinimalProvider` structure containing chat and embedding model arrays. For runtime model instantiation, `loadChatModel` and `loadEmbeddingModel` (lines 74-92) locate providers by ID and delegate to the provider's implementation, returning concrete `BaseLLM` instances ready for inference.

### Dynamic Provider Management

The registry supports runtime modification through several lifecycle methods:

- **`addProvider`** – Persists new provider configuration and updates the in-memory array
- **`removeProvider`** – Deletes provider entries from both configuration and runtime state
- **`updateProvider`** – Modifies existing provider settings
- **`addProviderModel` and `removeProviderModel`** – Manage individual models within a provider

These operations (lines 94-199 in [`src/lib/models/registry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/registry.ts)) synchronize changes with `configManager` from [`src/lib/config/index.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/config/index.ts), ensuring persistence across application restarts.

## Architecture Integration

The registry does not operate in isolation. It depends on the abstract `BaseModelProvider` class defined in [`src/lib/models/base/provider.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/base/provider.ts), which all concrete providers must implement. The `createProviderInstance` helper (lines 35-43 in the base file) validates configurations and constructs provider instances that the registry then manages.

Configuration management flows through [`src/lib/config/serverRegistry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/config/serverRegistry.ts), which supplies the initial list of enabled providers, while [`src/lib/config/index.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/config/index.ts) handles persistence for any runtime modifications made via the registry's CRUD operations.

## Practical Usage Examples

### Listing Active Providers and Models

To discover available providers and their models:

```typescript
import ModelRegistry from '@/lib/models/registry';

async function listProviders() {
  const registry = new ModelRegistry();
  const providers = await registry.getActiveProviders();
  console.log(providers);
  // → [{ id, name, chatModels: [...], embeddingModels: [...] }, …]
}

listProviders();

```

### Loading a Specific Chat Model

To instantiate a concrete model for inference:

```typescript
import ModelRegistry from '@/lib/models/registry';

async function useChatModel(providerId: string, modelName: string) {
  const registry = new ModelRegistry();
  const chatModel = await registry.loadChatModel(providerId, modelName);
  // `chatModel` is an instance of a concrete BaseLLM implementation
  const response = await chatModel.generate('Hello, world!');
  console.log(response);
}

useChatModel('openai-1', 'gpt-4o-mini');

```

### Adding a Provider at Runtime

To dynamically register new providers without restarting:

```typescript
import ModelRegistry from '@/lib/models/registry';

async function addOpenAIProvider() {
  const registry = new ModelRegistry();
  const newProvider = await registry.addProvider(
    'openai',                     // provider type (matches a key in `providers/`)
    'My OpenAI Provider',         // friendly name
    { apiKey: 'sk-xxxx', model: 'gpt-4o-mini' } // provider‑specific config
  );
  console.log('Added provider:', newProvider);
}

addOpenAIProvider();

```

## Summary

- The **Vane model registry implementation** lives in [`src/lib/models/registry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/registry.ts) as the `ModelRegistry` class.
- It **loads providers** via `getConfiguredModelProviders` and `createProviderInstance`, reading from [`src/lib/config/serverRegistry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/config/serverRegistry.ts).
- It **exposes active providers** through `getActiveProviders()` and loads models via `loadChatModel` and `loadEmbeddingModel`.
- It **manages provider lifecycles** with methods like `addProvider`, `removeProvider`, and `updateProvider`, persisting changes through `configManager`.
- It integrates with the **abstract `BaseModelProvider`** from [`src/lib/models/base/provider.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/base/provider.ts) to maintain provider-agnostic operations.

## Frequently Asked Questions

### Where exactly is the Vane model registry implementation located?

The primary implementation resides in [`src/lib/models/registry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/registry.ts) within the ItzCrazyKns/Vane repository. This file contains the `ModelRegistry` class that serves as the central hub for all model and provider operations, including initialization, discovery, and lifecycle management.

### How does ModelRegistry instantiate different LLM providers?

The registry uses the `createProviderInstance` helper defined in [`src/lib/models/base/provider.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/base/provider.ts) to construct provider instances. This function validates configuration objects against the abstract `BaseModelProvider` interface and returns concrete implementations from `src/lib/models/providers/`, allowing the registry to treat all providers uniformly regardless of their underlying API.

### Can I add or remove providers while Vane is running?

Yes. The `ModelRegistry` class exposes `addProvider`, `removeProvider`, `updateProvider`, `addProviderModel`, and `removeProviderModel` methods that modify both the in-memory provider array and the persistent configuration via `configManager`. These changes take effect immediately without requiring an application restart.

### What configuration files does the model registry depend on?

The registry reads initial provider configurations from [`src/lib/config/serverRegistry.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/config/serverRegistry.ts) through `getConfiguredModelProviders`. Runtime modifications are persisted via `configManager` in [`src/lib/config/index.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/config/index.ts). The registry also references provider definitions located in `src/lib/models/providers/` and the base contract in [`src/lib/models/base/provider.ts`](https://github.com/ItzCrazyKns/Vane/blob/main/src/lib/models/base/provider.ts).