Skip to main content

Embedding API

All the following functions, types, interfaces are exported by the library.

embed function

Converts text into numerical vectors

Signature:

function embed(options: EmbedOptions): Promise<Result<{
embeddings: Array<Embedding>;
}, RequestError>>;

Parameters

ParameterType
optionsEmbeddingOptions

Returns:

Promise<Result<{ embeddings: Array&lt;[Embedding](#embedding)<!-- -->&gt;; }, RequestError>>

EmbeddingOptions

Options for embedding request

Signature:

interface EmbeddingOptions

Properties

PropertyModifiersTypeDescription
contentArray<string>The strings to embed, the returned embedding will correspond to the order of the passed string
extraParams?Record<string, unknown>(Optional) Allows extra model specific parameters. Consult with the documentation
modelEmbeddingModelThe model to embed with

Embedding

Embedding vector returned by an embedding request

Signature:

interface Embedding

Properties

PropertyTypeDescription
truncatedbooleanIndicates if the input text was longer than max allowed tokens and truncated
valuesArray<number>The embedding vectors corresponding to the words in the input text

EmbeddingModel

Available models for text embedding

Signature:

type EmbeddingModel = 'textembedding-gecko';
Was this helpful?