A class for generating embeddings using the Jina API.

// Embed a query using the JinaEmbeddings class
const model = new JinaEmbeddings();
const res = await model.embedQuery(
"What would be a good name for a semantic search engine ?",
);
console.log({ res });

Hierarchy (view full)

Implements

Constructors

Properties

apiKey: string

The API key to use for authentication. If not provided, it will be read from the JINA_API_KEY environment variable.

model: string

The model ID to use for generating embeddings. Default: jina-embeddings-v2-base-en

Methods

  • Generates embeddings for an array of texts.

    Parameters

    • texts: string[]

      An array of strings to generate embeddings for.

    Returns Promise<number[][]>

    A Promise that resolves to an array of embeddings.

  • Generates embeddings for an array of image URIs.

    Parameters

    • uris: string[]

      An array of image URIs to generate embeddings for.

    Returns Promise<number[][]>

    A Promise that resolves to an array of embeddings.

  • Generates an embedding for a single text.

    Parameters

    • text: string

      A string to generate an embedding for.

    Returns Promise<number[]>

    A Promise that resolves to an array of numbers representing the embedding.