High-Throughput Email Agents with Fireworks AI

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.

Built for Fireworks AI API developers

High-Throughput Email Processing

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.

Graduated Trust via Oversight Modes

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.

Production-Ready Infrastructure

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.

OpenAI-Compatible Format

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.

Fine-Tuned Model Support

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.


Get started in minutes

Define MultiMail Tools for Fireworks AI
python
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.

Build an Email Agent with Fireworks AI
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 = 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.

High-Volume Email Processing Pipeline
python
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 results

Process large email volumes efficiently using Fireworks' throughput optimization.


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 Fireworks AI Python SDK and requests library for calling the MultiMail API.

bash
pip install fireworks-ai requests
3

Define Email Tool Schemas

Create tool definitions for send_email, check_inbox, and other MultiMail operations. Fireworks uses the OpenAI-compatible format.

4

Build the Agent Loop

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

bash
response = fireworks.client.ChatCompletion.create(
    model="accounts/fireworks/models/llama-v3p3-70b-instruct",
    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

What makes Fireworks AI good for email agents?
Fireworks AI is optimized for high-throughput, low-latency inference. This makes it ideal for email agents that need to process large volumes — triage hundreds of emails, generate batch replies, or categorize incoming mail. The throughput advantage translates directly to faster email workflows.
What happens when my agent 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.
Can I use a fine-tuned model with Fireworks and MultiMail?
Yes. Fireworks supports serving fine-tuned models. Fine-tune a model on your email style and domain-specific terminology, deploy it on Fireworks, and connect it to MultiMail. This produces higher-quality drafts that need less human editing during the approval step.
How do I handle high-volume email processing?
Use parallel threads to send multiple inference requests to Fireworks simultaneously, each processing a different email against MultiMail's API. Fireworks' throughput optimization handles concurrent requests well, and MultiMail's API supports high request rates on paid plans.
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.