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.
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.
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.
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.
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.
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.
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.
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_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.
Sign up at multimail.dev, create a mailbox, and generate an API key from your dashboard. Your key will start with mm_live_.
Install the Mistral AI Python SDK and requests library for calling the MultiMail API.
pip install mistralai requestsCreate tool definitions for send_email, check_inbox, and other MultiMail operations using Mistral's function calling format.
Implement a loop that sends messages to Mistral, checks for tool_calls, executes tools against MultiMail, and returns results.
response = client.chat.complete(
model="mistral-large-latest",
tools=email_tools,
messages=messages
)If your mailbox uses gated_send mode (the default), review and approve pending emails in the MultiMail dashboard before they are delivered.
Email infrastructure built for AI agents. Verifiable identity, graduated oversight, and a 38-tool MCP server. Formally verified in Lean 4.