OpenAIEmbeddings class

A EmbeddingsModel for calling OpenAI and Azure OpenAI hosted models.

Constructors

OpenAIEmbeddings(OpenAIEmbeddingsOptions | AzureOpenAIEmbeddingsOptions)

Creates a new OpenAIEmbeddings instance.

Properties

options

Options the client was configured with.

Methods

createEmbeddings(string, string | string[])

Creates embeddings for the given inputs using the OpenAI API.

Constructor Details

OpenAIEmbeddings(OpenAIEmbeddingsOptions | AzureOpenAIEmbeddingsOptions)

Creates a new OpenAIEmbeddings instance.

new OpenAIEmbeddings(options: OpenAIEmbeddingsOptions | AzureOpenAIEmbeddingsOptions)

Parameters

options

OpenAIEmbeddingsOptions | AzureOpenAIEmbeddingsOptions

Options for configuring the embeddings client.

Property Details

options

Options the client was configured with.

options: OpenAIEmbeddingsOptions | OpenAILikeEmbeddingsOptions | AzureOpenAIEmbeddingsOptions

Property Value

Method Details

createEmbeddings(string, string | string[])

Creates embeddings for the given inputs using the OpenAI API.

function createEmbeddings(model: string, inputs: string | string[]): Promise<EmbeddingsResponse>

Parameters

model

string

Name of the model to use (or deployment for Azure).

inputs

string | string[]

Text inputs to create embeddings for.

Returns

Promise<EmbeddingsResponse>

A EmbeddingsResponse with a status and the generated embeddings or a message when an error occurs.