MistralAIEmbeddings#

class langchain_mistralai.embeddings.MistralAIEmbeddings[source]#

Bases: BaseModel, Embeddings

MistralAI embedding models.

To use, set the environment variable MISTRAL_API_KEY is set with your API key or pass it as a named parameter to the constructor.

Example

from langchain_mistralai import MistralAIEmbeddings

mistral = MistralAIEmbeddings(
    model="mistral-embed",
    api_key="my-api-key"
)

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param endpoint: str = 'https://api.mistral.ai/v1/'#
param max_concurrent_requests: int = 64#
param max_retries: int = 5#
param mistral_api_key: SecretStr | None = None (alias 'api_key')#
Constraints:
  • type = string

  • writeOnly = True

  • format = password

param model: str = 'mistral-embed'#
param timeout: int = 120#
param tokenizer: Tokenizer = None#
async aembed_documents(texts: List[str]) List[List[float]][source]#

Embed a list of document texts.

Parameters:

texts (List[str]) – The list of texts to embed.

Returns:

List of embeddings, one for each text.

Return type:

List[List[float]]

async aembed_query(text: str) List[float][source]#

Embed a single query text.

Parameters:

text (str) – The text to embed.

Returns:

Embedding for the text.

Return type:

List[float]

embed_documents(texts: List[str]) List[List[float]][source]#

Embed a list of document texts.

Parameters:

texts (List[str]) – The list of texts to embed.

Returns:

List of embeddings, one for each text.

Return type:

List[List[float]]

embed_query(text: str) List[float][source]#

Embed a single query text.

Parameters:

text (str) – The text to embed.

Returns:

Embedding for the text.

Return type:

List[float]

Examples using MistralAIEmbeddings#