Combine Fireworks AI's optimized inference with MultiMail's email infrastructure for agents that handle high-volume email workflows with human oversight.
Fireworks AI specializes in fast, cost-effective inference for open-source models with function calling support. MultiMail provides the email infrastructure layer that turns Fireworks' throughput advantage into production email agents capable of processing large volumes efficiently.
By integrating MultiMail with the Fireworks AI API, your agents can handle high-volume email workflows while respecting human oversight boundaries. The default gated_send mode means your agent drafts emails at scale but humans approve before delivery, using MultiMail's batch review features.
Connect Fireworks to MultiMail by defining email tools in Fireworks' OpenAI-compatible function calling format and routing calls to the MultiMail REST API. The familiar API format minimizes integration effort.
Fireworks AI is optimized for high-throughput inference. Combined with MultiMail's email API, your agent can process hundreds of emails per minute for triage, categorization, and draft composition.
Start with gated_send (agent composes, human approves) and progress to autonomous as trust builds. MultiMail's five oversight modes let you safely scale from supervised to fully autonomous email agents.
Both Fireworks AI and MultiMail are built for production workloads. Fireworks handles model serving with high uptime, while MultiMail handles email delivery, thread tracking, and compliance.
Fireworks follows the OpenAI function calling format. Migrate email agent code from OpenAI or other compatible providers by changing only the base URL and model name.
Fireworks supports serving fine-tuned models. Train a model on your email domain and serve it through Fireworks for higher-quality email drafts with MultiMail oversight.
import fireworks.client
import requests
import json
fireworks.client.api_key = "your_fireworks_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"},
"subject": {"type": "string", "description": "Subject line"},
"body": {"type": "string", "description": "Email body"}
},
"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"}
},
"required": ["mailbox_id"]
}
}
}
]Create tool definitions using Fireworks' OpenAI-compatible 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 = fireworks.client.ChatCompletion.create(
model="accounts/fireworks/models/llama-v3p3-70b-instruct",
messages=messages,
tools=email_tools
)
msg = response.choices[0].message
if hasattr(msg, &"cm">#039;tool_calls') and msg.tool_calls:
messages.append(msg)
for tc in msg.tool_calls:
result = execute_tool(tc.function.name, json.loads(tc.function.arguments))
messages.append({
"role": "tool", "tool_call_id": tc.id,
"content": json.dumps(result)
})
else:
return msg.content
print(run_email_agent("Check my inbox", "mbx_abc123"))Create an agentic loop using Fireworks' chat completions with MultiMail tools.
from concurrent.futures import ThreadPoolExecutor
def categorize_email(email):
"""Categorize a single email using Fireworks&"cm">#039; fast inference."""
response = fireworks.client.ChatCompletion.create(
model="accounts/fireworks/models/llama-v3p3-70b-instruct",
messages=[
{"role": "system", "content": "Categorize this email. Return JSON: "
&"cm">#039;{"category": "urgent|action|info|spam", "summary": "..."}'},
{"role": "user", "content": f"From: {email[&"cm">#039;from']}\n"
f"Subject: {email[&"cm">#039;subject']}\nBody: {email['body']}"}
]
)
result = json.loads(response.choices[0].message.content)
# Tag in MultiMail
requests.post(
f"{MULTIMAIL_API}/emails/{email[&"cm">#039;id']}/tag",
headers=MM_HEADERS, json={"tag": result["category"]}
)
return {"id": email["id"], **result}
def process_inbox(mailbox_id, batch_size=50):
resp = requests.get(
f"{MULTIMAIL_API}/mailboxes/{mailbox_id}/inbox",
headers=MM_HEADERS, params={"limit": batch_size}
)
emails = resp.json().get("messages", [])
"cm"># Process in parallel for maximum throughput
with ThreadPoolExecutor(max_workers=10) as executor:
results = list(executor.map(categorize_email, emails))
return resultsProcess large email volumes efficiently using Fireworks' throughput optimization.
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 Fireworks AI Python SDK and requests library for calling the MultiMail API.
pip install fireworks-ai requestsCreate tool definitions for send_email, check_inbox, and other MultiMail operations. Fireworks uses the OpenAI-compatible format.
Implement a loop that sends messages to Fireworks, checks for tool_calls, executes tools against MultiMail, and returns results.
response = fireworks.client.ChatCompletion.create(
model="accounts/fireworks/models/llama-v3p3-70b-instruct",
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.