Skip to main content
Version: V1.4.1

Mistral

Mistral lets you run and manage open-source models locally and provides an OpenAI-compatible API for generating embeddings. seekdb exposes MistralEmbeddingFunction, which calls Mistral embedding models through an OpenAI-compatible interface.

tip

Using OpenAI services requires you to follow OpenAI's pricing rules and may incur corresponding fees. Before proceeding, visit the official website or read the relevant documentation to confirm and accept their pricing. If you do not agree, do not continue.

Dependencies and environment​

MistralEmbeddingFunction calls Mistral embedding models through an OpenAI-compatible interface. You typically need:

The pyseekdb and openai packages installed in your Python environment.

pip install pyseekdb openai

Example: create a Mistral embedding function​

  • Use a Mistral text embedding model

    import pyseekdb
    from pyseekdb.utils.embedding_functions import MistralEmbeddingFunction

    ef = MistralEmbeddingFunction(model_name="mistral-embed")
  • Use additional parameters

    import pyseekdb
    from pyseekdb.utils.embedding_functions import MistralEmbeddingFunction

    ef = MistralEmbeddingFunction(
    model_name="mistral-embed",
    timeout=30,
    max_retries=3
    )

Parameters:

  • model_name (str, optional): Mistral embedding model name. Default is mistral-embed.

  • api_key_env (str, optional): Environment variable name that holds the Mistral API key. If omitted, defaults to MISTRAL_API_KEY.

  • api_base (str, optional): Base URL for the Mistral API endpoint. If omitted, defaults to https://api.mistral.ai/v1.

  • kwargs: Additional arguments passed to the OpenAI client.

    Common options:

    • timeout: Request timeout in seconds.
    • max_retries: Maximum number of retries.