Use DSPy's declarative programming model to build email agents that improve automatically through optimization — with MultiMail handling delivery and human oversight.
DSPy is a framework from Stanford for programming with foundation models using signatures and optimizers rather than manual prompt engineering. Instead of writing prompts, you declare what the model should do, and DSPy compiles your declarations into optimized prompts. MultiMail provides the email infrastructure that DSPy modules need to actually send, receive, and manage messages.
By integrating MultiMail with DSPy, you can build email agents where the email composition logic is optimized automatically. Define signatures for tasks like 'compose a professional reply' or 'classify email urgency,' and let DSPy's optimizers find the best prompt strategies. MultiMail handles the delivery with configurable human oversight.
DSPy's assertion system complements MultiMail's oversight modes. Assertions validate email content quality at the generation level, while MultiMail's gated_send mode adds human judgment at the delivery level. Together they ensure both content quality and send authorization.
DSPy's optimizers automatically improve your email drafting prompts based on metrics. Define what a good email reply looks like, provide examples, and let DSPy find the optimal prompting strategy for your use case.
DSPy's assertion system validates email content quality (length, tone, completeness). MultiMail's oversight modes handle delivery safety (correct recipients, appropriate timing). Together they cover both content and delivery concerns.
Define email tasks as DSPy signatures rather than writing complex prompts. A signature like 'email_content -> professional_reply' is clearer and more maintainable than a hand-crafted prompt, and DSPy optimizes it automatically.
Use DSPy's metric system to measure email quality. Track response relevance, tone appropriateness, and accuracy against your knowledge base, then optimize your modules to maximize these metrics.
While DSPy optimizes the intelligence layer, MultiMail provides production-grade email delivery, thread tracking, contact management, and audit logging. Each handles what it does best.
No code, no dashboard. Paste this to your AI agent — it connects MultiMail, creates an inbox, and builds the flow for you.
Sign up at multimail.dev, create a mailbox, and generate an API key. Your key will start with mm_live_.
Install DSPy and requests for calling the MultiMail API.
Create DSPy Signature classes that declare your email tasks — classification, composition, and any other email processing steps.
Create a DSPy Module that chains your signatures together and calls the MultiMail API for delivery. Add assertions for content validation.
Define quality metrics and use DSPy's optimizers to improve your email agent. Review pending emails in the MultiMail dashboard when using gated_send mode.
Email infrastructure built for AI agents. Verifiable identity, graduated oversight, and a hosted MCP server. Formally verified in Lean 4.