@multimail/ai-sdk
MultiMail tools for the Vercel AI SDK. Give any AI agent the ability to send and read email through MultiMail.
Installation
npm install @multimail/ai-sdk ai zod
Quick Start
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { createMultiMailTools } from '@multimail/ai-sdk';
const tools = createMultiMailTools(process.env.MULTIMAIL_API_KEY!);
const { text } = await generateText({
model: openai('gpt-4o'),
tools,
maxSteps: 5,
prompt: 'Check my inbox for unread emails and summarize them.',
});
Streaming
import { streamText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { createMultiMailTools } from '@multimail/ai-sdk';
const tools = createMultiMailTools(process.env.MULTIMAIL_API_KEY!);
const result = streamText({
model: anthropic('claude-sonnet-4-20250514'),
tools,
maxSteps: 5,
prompt: 'Reply to the latest email from alice@example.com saying thanks.',
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}
Tools
listMailboxes | List all mailboxes on the account |
checkInbox | List emails with filtering (status, sender, subject, direction, dates) |
readEmail | Read full email content (markdown body, attachments, tags) |
sendEmail | Send a new email with markdown body |
replyEmail | Reply to an existing email (auto-threads) |
searchContacts | Search contacts by name or email |
listPending | List emails awaiting human approval |
decideEmail | Approve or reject a pending email |
getThread | Get all emails in a conversation thread |
tagEmail | Add key-value tags to an email |
Configuration
const tools = createMultiMailTools('mm_live_...', {
baseUrl: 'https://api-staging.multimail.dev',
});
Oversight Modes
MultiMail enforces graduated trust through oversight modes. Depending on the mailbox configuration, outbound emails may require human approval before delivery. The listPending and decideEmail tools let agents participate in the approval workflow.
Learn more at multimail.dev/docs.
License
MIT