Mistral

Use Mistral models with Agno agents.

Mistral provides API endpoints for its large language models. See their library of models here.

We recommend experimenting to find the best-suited model for your use-case. Here are some general recommendations:

  • codestral model is good for code generation and editing.
  • mistral-large-latest model is good for most use-cases.
  • For a smaller model, consult the current catalog. Mistral NeMo is deprecated; Mistral recommends Ministral 3 8B for new integrations.
  • ministral-14b-2512 supports vision tasks such as OCR, document transcription, and image comparison.

Check your Mistral account for current usage limits and the pricing guide for hosted inference costs.

Installation

uv pip install -U mistralai agno

Authentication

Set your MISTRAL_API_KEY environment variable. Get your key from here.

export MISTRAL_API_KEY="YOUR_API_KEY"

Example

Use MistralChat with your Agent:

import os

from agno.agent import Agent
from agno.models.mistral import MistralChat

mistral_api_key = os.getenv("MISTRAL_API_KEY")

agent = Agent(
    model=MistralChat(
        id="mistral-large-latest",
        api_key=mistral_api_key,
    ),
    markdown=True
)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story.")
View more examples here.

Params

ParameterTypeDefaultDescription
idstr"mistral-large-latest"The id of the Mistral model to use
namestr"MistralChat"The name of the model
providerstr"Mistral"The provider of the model
temperatureOptional[float]NoneControls randomness in the model's output
max_tokensOptional[int]NoneMaximum number of tokens to generate
top_pOptional[float]NoneControls diversity via nucleus sampling
random_seedOptional[int]NoneRandom seed for reproducibility
safe_modeboolFalseLegacy field; True is rejected by the current Mistral SDK. Leave False.
safe_promptboolFalseForward Mistral's legacy safety-prompt option; this is not an application guardrail.
request_paramsOptional[Dict[str, Any]]NoneAdditional parameters for the request
api_keyOptional[str]NoneThe API key for Mistral (defaults to MISTRAL_API_KEY env var)
endpointOptional[str]NoneDeclared field rejected by Mistral SDK 2 when set. Leave None and use the current SDK configuration below.
max_retriesOptional[int]NoneDeclared field rejected by Mistral SDK 2 when set. Leave None and use the current SDK configuration below.
timeoutOptional[int]NoneDeclared field rejected by Mistral SDK 2 when set. Leave None and use the current SDK configuration below.
client_paramsOptional[Dict[str, Any]]NoneAdditional parameters for client configuration
mistral_clientOptional[Mistral]NoneA pre-configured Mistral client instance to use

Configure the Mistral SDK

With Mistral SDK 2, pass supported constructor options through client_params while leaving endpoint, timeout and max_retries unset. For example, set a 15-second timeout and disable SDK retries:

model = MistralChat(
    client_params={
        "server_url": "https://api.mistral.ai",
        "timeout_ms": 15000,
        "retry_config": None,
    },
)

timeout_ms is in milliseconds. For custom retries, pass the SDK's RetryConfig object as retry_config; it is not an integer retry count. You can also supply a configured mistralai.client.Mistral through mistral_client. See the official Python SDK.

MistralChat is a subclass of the Model class and has access to the same params.