Cost-Efficient Email Agents with Mistral AI

Use Mistral's function calling to build email agents powered by MultiMail — efficient models, full email capabilities, and configurable human oversight.


Mistral AI offers a range of efficient models with function calling support, making it a popular choice for cost-sensitive agent deployments. MultiMail provides the email infrastructure layer that Mistral-powered agents need to send, receive, and manage email on behalf of users.

By integrating MultiMail with the Mistral API, you get enterprise-grade email oversight without the cost of more expensive model APIs. The default gated_send mode means your Mistral agent drafts emails but a human approves before delivery, adding safety without increasing inference costs.

Connect Mistral to MultiMail by defining email tools in Mistral's function calling format and routing calls to the MultiMail REST API, or use the @multimail/mcp-server for automatic tool discovery.

Built for Mistral API developers

Cost-Efficient Email Agents

Mistral's models offer competitive pricing for function calling workloads. Combined with MultiMail's email infrastructure, you can build production email agents at a fraction of the cost of larger model APIs.

Graduated Trust via Oversight Modes

Start with gated_send (Mistral composes, human approves) and progress to autonomous as trust builds. MultiMail's five oversight modes let you match agent autonomy to your confidence in the model's output quality.

Function Calling Compatibility

Mistral's function calling follows the same patterns as other major APIs. Define send_email, check_inbox, and reply_email as tool functions with typed parameters, and Mistral generates structured calls reliably.

Open and Commercial Model Options

Mistral offers both open-weight and commercial models with function calling. Choose the right model for your email agent based on cost, quality, and deployment requirements.

MCP Server Integration

The @multimail/mcp-server package exposes email tools in the Model Context Protocol format. Use MCP adapters to automatically discover and register all MultiMail tools with your Mistral-powered agent.


Get started in minutes

Define MultiMail Tools for Mistral
python
from mistralai import Mistral
import requests
import json

client = Mistral(api_key="your_mistral_api_key")
MULTIMAIL_API = "https://api.multimail.dev/v1"
MM_HEADERS = {"Authorization": "Bearer mm_live_your_api_key"}

email_tools = [
    {
        "type": "function",
        "function": {
            "name": "send_email",
            "description": "Send an email through MultiMail. In gated_send mode, queues for human approval.",
            "parameters": {
                "type": "object",
                "properties": {
                    "mailbox_id": {"type": "string", "description": "Mailbox to send from"},
                    "to": {"type": "string", "description": "Recipient email address"},
                    "subject": {"type": "string", "description": "Email subject line"},
                    "body": {"type": "string", "description": "Email body content"}
                },
                "required": ["mailbox_id", "to", "subject", "body"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "check_inbox",
            "description": "Check inbox for recent messages.",
            "parameters": {
                "type": "object",
                "properties": {
                    "mailbox_id": {"type": "string", "description": "Mailbox to check"},
                    "limit": {"type": "integer", "description": "Max messages to return"}
                },
                "required": ["mailbox_id"]
            }
        }
    }
]

Create tool definitions for email functions using Mistral's function calling format.

Build an Email Agent with Mistral
python
def execute_tool(name, args):
    if name == "send_email":
        resp = requests.post(f"{MULTIMAIL_API}/send", headers=MM_HEADERS, json=args)
    elif name == "check_inbox":
        resp = requests.get(
            f"{MULTIMAIL_API}/mailboxes/{args[&"cm">#039;mailbox_id']}/inbox",
            headers=MM_HEADERS, params={"limit": args.get("limit", 10)}
        )
    elif name == "reply_email":
        resp = requests.post(f"{MULTIMAIL_API}/reply", headers=MM_HEADERS, json=args)
    else:
        return {"error": f"Unknown tool: {name}"}
    return resp.json()

def run_email_agent(user_message, mailbox_id):
    messages = [
        {"role": "system", "content": f"You are an email assistant for mailbox {mailbox_id}. "
         f"Emails use gated_send mode and queue for human approval."},
        {"role": "user", "content": user_message}
    ]
    while True:
        response = client.chat.complete(
            model="mistral-large-latest",
            messages=messages,
            tools=email_tools
        )
        msg = response.choices[0].message
        if msg.tool_calls:
            messages.append({"role": "assistant", "content": "", "tool_calls": [
                {"id": tc.id, "function": {"name": tc.function.name,
                 "arguments": tc.function.arguments}} for tc in msg.tool_calls
            ]})
            for tc in msg.tool_calls:
                result = execute_tool(tc.function.name, json.loads(tc.function.arguments))
                messages.append({
                    "role": "tool", "name": tc.function.name,
                    "content": json.dumps(result), "tool_call_id": tc.id
                })
        else:
            return msg.content

print(run_email_agent("Check my inbox", "mbx_abc123"))

Create an agentic loop where Mistral calls MultiMail functions and processes results.

Tag and Organize Emails with Mistral
python
tag_email_fn = {
    "type": "function",
    "function": {
        "name": "tag_email",
        "description": "Tag an email with a category label.",
        "parameters": {
            "type": "object",
            "properties": {
                "message_id": {"type": "string", "description": "Message ID to tag"},
                "tag": {"type": "string", "description": "Tag to apply"}
            },
            "required": ["message_id", "tag"]
        }
    }
}

read_email_fn = {
    "type": "function",
    "function": {
        "name": "read_email",
        "description": "Read the full content of an email.",
        "parameters": {
            "type": "object",
            "properties": {
                "message_id": {"type": "string", "description": "Message ID to read"}
            },
            "required": ["message_id"]
        }
    }
}

all_tools = email_tools + [tag_email_fn, read_email_fn]

"cm"># Use a smaller, faster model for email triage
response = client.chat.complete(
    model="mistral-small-latest",
    messages=[{"role": "user", "content": "Read and categorize the latest 5 emails"}],
    tools=all_tools
)

Use Mistral's efficient models to categorize and tag incoming emails via MultiMail.


Step by step

1

Create a MultiMail Account and API Key

Sign up at multimail.dev, create a mailbox, and generate an API key from your dashboard. Your key will start with mm_live_.

2

Install Dependencies

Install the Mistral AI Python SDK and requests library for calling the MultiMail API.

bash
pip install mistralai requests
3

Define Email Tool Schemas

Create tool definitions for send_email, check_inbox, and other MultiMail operations using Mistral's function calling format.

4

Build the Agent Loop

Implement a loop that sends messages to Mistral, checks for tool_calls, executes tools against MultiMail, and returns results.

bash
response = client.chat.complete(
    model="mistral-large-latest",
    tools=email_tools,
    messages=messages
)
5

Approve Pending Emails

If your mailbox uses gated_send mode (the default), review and approve pending emails in the MultiMail dashboard before they are delivered.


Common questions

Which Mistral model should I use for email agents?
For email composition and complex reasoning, use mistral-large-latest. For email triage and tagging tasks that prioritize speed and cost, mistral-small-latest works well. Both support function calling, so you can mix models based on the task complexity.
What happens when Mistral sends an email in gated_send mode?
In gated_send mode, the MultiMail API returns a success response with a pending status. The email is queued for human review in the MultiMail dashboard. Once approved, it is delivered. Your agent can check the status of pending emails using the list_pending endpoint.
How does Mistral's cost compare to other providers for email agents?
Mistral's models are significantly cheaper per token than GPT-4 or Claude for function calling workloads. Since MultiMail's email tools require relatively simple structured outputs, even Mistral's smaller models handle them well, making it one of the most cost-effective options for production email agents.
Can I use Mistral's open models with MultiMail?
Yes. Mistral's open-weight models can be self-hosted and used with MultiMail's REST API. You would need to implement the function calling loop yourself, but the MultiMail API integration remains the same regardless of how you host the model.
Is there rate limiting on the MultiMail API?
Rate limits depend on your plan tier. The Starter (free) plan allows 200 emails per month, while paid plans range from 5,000 to 150,000. The API returns standard 429 responses when limits are reached, which your agent can handle with retry logic.

Explore more

The only agent email with a verifiable sender

Email infrastructure built for AI agents. Verifiable identity, graduated oversight, and a 38-tool MCP server. Formally verified in Lean 4.