Skip to content

@chinmaymk/aikit v0.0.40


@chinmaymk/aikit / createEmbeddingsProvider

Function: createEmbeddingsProvider()

Call Signature

createEmbeddingsProvider(type, options): OpenAIEmbeddingProvider

Defined in: factory.ts:187

Generic embeddings provider factory function with strong typing. Creates embedding providers with full type safety. Returns a narrowed type based on the provider type.

Parameters

type

"openai_embeddings"

options

WithApiKey<OpenAIEmbeddingOptions>

Returns

OpenAIEmbeddingProvider

Example

typescript
// Strongly typed - options are specific to the provider type
const openaiEmbeddings = createEmbeddingsProvider('openai_embeddings', {
  apiKey: 'sk-...',
  model: 'text-embedding-3-large',
  dimensions: 1024  // OpenAI-specific option
});

const googleEmbeddings = createEmbeddingsProvider('google_embeddings', {
  apiKey: 'AIza...',
  model: 'text-embedding-004'
});

Call Signature

createEmbeddingsProvider(type, options): GoogleEmbeddingProvider

Defined in: factory.ts:191

Generic embeddings provider factory function with strong typing. Creates embedding providers with full type safety. Returns a narrowed type based on the provider type.

Parameters

type

"google_embeddings"

options

WithApiKey<GoogleEmbeddingOptions>

Returns

GoogleEmbeddingProvider

Example

typescript
// Strongly typed - options are specific to the provider type
const openaiEmbeddings = createEmbeddingsProvider('openai_embeddings', {
  apiKey: 'sk-...',
  model: 'text-embedding-3-large',
  dimensions: 1024  // OpenAI-specific option
});

const googleEmbeddings = createEmbeddingsProvider('google_embeddings', {
  apiKey: 'AIza...',
  model: 'text-embedding-004'
});

Call Signature

createEmbeddingsProvider(type, options): AnyEmbeddingProvider

Defined in: factory.ts:195

Generic embeddings provider factory function with strong typing. Creates embedding providers with full type safety. Returns a narrowed type based on the provider type.

Parameters

type

EmbeddingProviderType

options

WithApiKey<OpenAIEmbeddingOptions | GoogleEmbeddingOptions>

Returns

AnyEmbeddingProvider

Example

typescript
// Strongly typed - options are specific to the provider type
const openaiEmbeddings = createEmbeddingsProvider('openai_embeddings', {
  apiKey: 'sk-...',
  model: 'text-embedding-3-large',
  dimensions: 1024  // OpenAI-specific option
});

const googleEmbeddings = createEmbeddingsProvider('google_embeddings', {
  apiKey: 'AIza...',
  model: 'text-embedding-004'
});

Released under the MIT License.