Skip to main content

MistralAI

This notebook explains how to use MistralAIEmbeddings, which is included in the langchain_mistralai package, to embed texts in langchain.

# pip install -U langchain-mistralai

import the library​

from langchain_mistralai import MistralAIEmbeddings
embedding = MistralAIEmbeddings(mistral_api_key="your-api-key")

Using the Embedding Model

With MistralAIEmbeddings, you can directly use the default model β€˜mistral-embed’, or set a different one if available.

embedding.model = "mistral-embed"  # or your preferred model if available
res_query = embedding.embed_query("The test information")
res_document = embedding.embed_documents(["test1", "another test"])