Skip to main content

Mistral AI

The MistralAIEmbeddings class uses the Mistral AI API to generate embeddings for a given text.

Setup

In order to use the Mistral API you'll need an API key. You can sign up for a Mistral account and create an API key here.

You'll first need to install the @langchain/mistralai package:

npm install @langchain/mistralai

Usage

import { MistralAIEmbeddings } from "@langchain/mistralai";

/* Embed queries */
const embeddings = new MistralAIEmbeddings({
apiKey: process.env.MISTRAL_API_KEY,
});
const res = await embeddings.embedQuery("Hello world");
console.log(res);
/* Embed documents */
const documentRes = await embeddings.embedDocuments(["Hello world", "Bye bye"]);
console.log({ documentRes });

API Reference:


Was this page helpful?


You can leave detailed feedback on GitHub.